INSY 3433 Lecture 2: Lecture 2
Document Summary
Variable statements: define declare variable, not value, ex: int a, define/assign declare & assign, ex: int a = 1, assign set value of previously defined variable, ex: a = 1; If/else if/else choose between 3 sets of statements: switch choose between multiple statements. Repetition statements: the for statement allows repetition of statement(s, the while statement is similar to a for loop, the do-while statement is similar to a while loop for has at least 1 repetition. Input statement setup: java scanner class is one way to get input, statement import java. util. scanner; before class statement to indicate scanner class is needed, statement scanner variablename = new scanner(system. in); needed once w/ system. in indicating keyboard input. Input statement getting: once a scanner variable is set, it can be used in subsequent statement to get different types of input data, ex: string firstname = inp. next(), ex: int c = inp. nextint(), ex: double average = inp. nextdouble();