1 / 9

Welcome to AP Computer Science A

Welcome to AP Computer Science A. We use the Java language, but this class is much more rigorous than Intro to Java More programming, but also more theory Difficult material…expect to study/practice at home if you want to succeed

lee-hewitt
Download Presentation

Welcome to AP Computer Science A

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. Welcome to AP Computer Science A • We use the Java language, but this class is much more rigorous than Intro to Java • More programming, but also more theory • Difficult material…expect to study/practice at home if you want to succeed • AP Exam: May 7th 2015… college credit  save $$ and time, impressive on application, be more prepared for college • cbsd.org  teacher websites  Quinn • Notes, assignments, and test/quiz dates will be posted here. When you miss class, it is YOUR responsibility to read the notes and complete the assignments.

  2. Rules for naming a file • Begin with a capital letter • No spaces or punctuation • Cannot begin with a number • Each new word starts with a capital letter

  3. Basic output • To display text: System.out.println(“ “); • To go to the next line: put \n between the quotes • System.out.print(“ “);  do not go to next line • Java is case-sensitive • Semi-colons after (almost) every line of code • Demo: HelloWorld

  4. Variables • Variables are memory containers in which info is stored • They can hold numbers, letters, words, phrases, etc • integers are whole numbers (no decimals) • First, declare the variable – specify the type of info the variable will hold, and give the variable a name int x = 0; • Setting it equal to zero is called initializing the variable (giving it an initial value) • Integers are usually initialized to 0, although there are exceptions to this rule • Demo

  5. You give a variable a value by using =, which is called the assignment operator. • Important: = does not mean “is equal to!” • What it really means is “Take what is on the right side of the equals sign and assign it to what is on the left side.”

  6. Rules for naming variables • Use meaningful names • Cannot start with a number • Numbers and letters only • Start with a lowercase letter • then capitalize the first letter of other words • Examples: highScore avgTestScore

  7. Other types of variables • Double (also known as “floating point number”) • allows decimals • much more useful than integers, but takes up more memory • char • A single character • You must put the character in single quotes, if you are giving a char value in your code example: char myGrade = ‘ ’; • String • Words, phrases, sentences • Capitalize String • Use double quotes example: String firstName= “”; • Demo

  8. Arithmetic • You can perform arithmetic with numbers and/or variables. • Java follows mathematical order of operations (PEMDAS). • Example: 4 + 36 / 2  this equals 22, not 20.

  9. Assignments • (MyInfo) • Create variables that will hold… • your age • 9 numbers • The average of those 9 numbers • The product of the first and last numbers • your middle initial • Your favorite book • Store data in these variables. • Then display this information. • P117 #2, 3 name these programs like this: P117num2

More Related