1 / 18

AP Computer Science

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 start an operating system. Java 101. What happens when you run a program?

lynley
Download Presentation

AP Computer Science

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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 don’t need an instance to call this method • void = this method doesn’t 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 else’s 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 while’s 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?

More Related