Chapter 3 1
Announcements
- Project 2 has been posted
– Due Feb 1st at 10:00pm – Work ALONE!
- Help hours
– Monday – Thursday, 7-10pm – LWSN B146
- Quiz solutions will be on newsgroup
- Sign up for newsgroup!
- We expect you to be reading book. These slides
Announcements Project 2 has been posted Due Feb 1st at 10:00pm - - PowerPoint PPT Presentation
Announcements Project 2 has been posted Due Feb 1st at 10:00pm Work ALONE! Help hours Monday Thursday, 7-10pm LWSN B146 Quiz solutions will be on newsgroup Sign up for newsgroup! We expect you to be
Chapter 3 1
Chapter 3 2
Chapter 3
Chapter 3 3
Chapter 3 4
if (count < 3) { total = 0; count = 0; }
Chapter 3 5
– if (s1 == s2), where s1 and s2 refer to
Chapter 3 6
Chapter 3 7
switch followed by an integral expression in
Chapter 3 8
Chapter 3 9
Chapter 3 10
Chapter 3 11
Chapter 3 12
for (count = 1; count < 5; count++) System.out.println(count); System.out.println(“Done”);
Chapter 3 13
Chapter 3 14
break statement.
Chapter 3 15
Chapter 3 16
System.exit(0).
if (numberOfWinners == 0) { System.out.println(“cannot divide by 0”); System.exit(0); }
Chapter 3 17
Chapter 3 18
Chapter 3 19
Chapter 3 20
Chapter 3 21
90 10
Chapter 3 22
int next = keyboard.nextInt(); while (next >= 0) { Process_The_Score next = keyboard.nextInt(); }
Chapter 3 23
Chapter 3 24
while loop.
Chapter 3 25
Chapter 3 26
Chapter 3 27
if (payment <= penalty) System.out.println(“payment is too small”); else { ...
Chapter 3 28
– < is used when <= should be used or <= is
Chapter 3 29
Chapter 3 30
Chapter 3 31
Chapter 3 32
Chapter 3 33
if((temperature <= 100) && (thrust >= 12000) && (cabinPressure > 30) && …)
Chapter 3 34
boolean all evaluate to either true or false.
boolean isPositive = (number > 0); ... if (isPositive) ...
Chapter 3 35
systemsAreOk.
systemStatus.
Chapter 3 36
Chapter 3 37
Chapter 3 38
Chapter 3 39
Chapter 3 40
Chapter 3 41
true, the expression is true.
false, the expression is false.
Chapter 3 42
if ((number != 0) && (sum/number > 5))
Chapter 3 43
boolean boo = false; System.out.println(boo); System.out.print(“Enter a boolean value: “); Scanner keyboard = new Scanner (System.in); boo = keyboard.nextBoolean(); System.out.println(boo);
Chapter 3 44
false Enter a boolean value: true true
Chapter 3 45
boolean numbersLeftToRead = true while (numbersLeftToRead) { next = keyboard.nextInt() if (next < 0) numbersLeftToRead = false; else Process_Next_Number }
Chapter 3 46
Chapter 3 47
Chapter 3 48
paint method, think of the drawing being done
canvas.setColor(Color.YELLOW);
Chapter 3 49
Chapter 3 50
Chapter 3 51
Chapter 3 52
Chapter 3 53
Chapter 3 54
canvas.drawString(“Hello”,10,20);
Graphics_Object.drawString(String, X, Y);
Chapter 3 55
Chapter 3 56
int answer = JOptionPane.showConfirmDialog(null, “End program?”, “Want to end?”, JOptionPane.YES_NO_OPTION); if (answer == JOptionPane.YES_OPTION) System.exit(0); else System.out.println(“once more”);
Chapter 3 57
Chapter 3 58
Chapter 3 59
Chapter 3 60