Presentation is loading. Please wait.

Presentation is loading. Please wait.

AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.

Similar presentations


Presentation on theme: "AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to."— Presentation transcript:

1 AP Computer Science Anthony Keen

2 Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to start an operating system.

3 Java 101 What happens when you run a program? You tell the operating system to run a program called java.exe with a command line argument, your program. Java starts up and then calls your main method.

4 Where does a program start? public static void main(String[] args) –public = anyone can call this method –static = you dont need an instance to call this method –void = this method doesnt return anything –main = the name of the method –String[] = this function takes an array of Strings as its parameter –args = the name of our array

5 Primitives int –Holds an Integer float, double –Holds a decimal value char –Holds a single character boolean –Holds true or false

6 Sequential Programming The statements within a function (like main) are executed in order.

7 Conditional Statements if(boolean) { // stuff } –if the boolean is true, then we execute the code inside the curly braces

8 Conditional Statements if(boolean) { // stuff } else { // different stuff } –if the boolean is false, then we execute the code inside the elses curly braces

9 Conditional Statements switch(int) { case 0: // stuff break; case 1: // other stuff break; default: // default stuff }

10 Looping Structures while (boolean) { // Stuff } While the boolean value is true, we will keep doing whatever is inside the whiles curly braces.

11 Looping Structures Typical Use: int count = 0; while (count < 10) { // Stuff count++; // count = count + 1; }

12 Looping Structures for (initialize; condition; increment) { // Stuff }

13 Looping Structures Typical use for (int i = 0; i < 10; i++) { // Stuff }

14 Input / Output Input –JOptionPane.showInputDialog ( … ) Output –System.out.print ( … ) –System.out.println ( … ) Escape Codes –\n = New Line –\t = Tab

15 In Review Primitives Sequential Programming Conditional Statements Looping Structures Input / Output

16 Operators =, is assigned to +, add numbers or concatenate Strings -, subtract numbers *, multiply numbers /, divide numbers %, divide numbers and give the remainder

17 Logic Operators &&, AND ||, OR ==, equal to !=, not equal to &, bitwise AND |, bitwise OR <, less than >, greater than

18 What else have we covered?


Download ppt "AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to."

Similar presentations


Ads by Google