CS 111 - 9/4/14 tshell2@uic.edu Follow Lab schedule as shown in http://www.cs.uic.edu/~grad/2014FallTA.pdf Labs on Mondays - Lab Quiz occurs first - TA will present the weekly lab assignment - Work on lab assignment & ask questions of TA Prof. Troy's office hours are planning to run from 11am to 2pm on Friday 9/5 -------------------------- Variable - hold information for the program to use The information is stored in the computers RAM memory while the program is executing We create variables and give them identifier names All identifiers must first start with a letter then can contain letters, digits or underscores Valid identifier: value number1 theSumOfTheValues the_sum_of_the_values val12next16 It better to have a descriptive/meaningful identifier name that just random characters dfgertgdf Invalid identifiers: 12thAddress room#17 The variable also needs a type associcated with it a type is an encoding scheme Some Java Types int - an integer value ex: 45 0 -17 3 double - a floating point value ex: 14.9 0.0 3.0 -0.000008 char - a character in ASCII format ex: 'e' '%' '3' String - a collection of characters ex: "Hello" "true" "1234" boolean - a true or false value ex: true false To create a variable: we write the following code int value1; Syntax: ; To use a variable, we most often use an assignment statement Syntax: = ; ex: value1 = 10; value2 = value1 + 5; value1 = value1 + 1; First: the expression is evaluated, Second: the resulting value is stored in the variable Primary arthemetic operators + addition - subraction * multiplication / division 5 + 4 * 3 ( ) parentheses (5 + 4) * 3 % modulus - remainder from an integer division 9 / 2 ==> 4 integer division 9.0 / 2.0 ==> 4.5 floating point division