lec06 - Lecture 6 Selection Boolean expressions and...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
CS125 Course Notes Lecture 6, Slide 1 Lecture 6 • Selection • Boolean expressions and operators (Savitch 3.1)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS125 Course Notes Lecture 6, Slide 2 Nested statements • We can put if-else statements inside each other. • There is no limit to how many times this can be done.
Background image of page 2
CS125 Course Notes Lecture 6, Slide 3 Nested statements continued if (numGuesses < maxGuesses) { if (guess == actualNum) System.out.println(“Correct”); else System.out.println(“Wrong”); numGuesses++; } else { System.out.println(“Out of guesses.”); }
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS125 Course Notes Lecture 6, Slide 4 Compound statements • Must put {} around multiple statements. • The result is a compound statement treated as a single statement. • Most commonly used in if-else statements, as we had already seen, and loops.
Background image of page 4
CS125 Course Notes Lecture 6, Slide 5 Multibranch statements • We can have more than two choices in an if-else statement.
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 15

lec06 - Lecture 6 Selection Boolean expressions and...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online