{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

07-feb06 - COMP110 TabithaPeckM.S February6,2008 MWF33:50pm...

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

View Full Document Right Arrow Icon
COMP 110 Switch Statements and Loops Tabitha Peck M.S. February 6, 2008 MWF 3-3:50 pm Philips 367 1
Background image of page 1

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

View Full Document Right Arrow Icon
Announcements Friday - No Lab! Bring questions on Project 2 Grades online next week 2
Background image of page 2
Questions? 3
Background image of page 3

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

View Full Document Right Arrow Icon
Switch Statements switch (numOfSiblings) { case 0: System.out.print(“An only child”); break ; case 1: System.out.print(“Just one you say”); break ; case 2: System.out.print(“Two siblings!”); break ; case 3: System.out.print(“Big family!”); break ; default : System.out.print(“I don’t believe you”); break ; } 4 Controlling expression     int or char ONLY! Break  statement Case  label
Background image of page 4
Practice with Switch statements Write a switch statement that takes as controlling expression your year in college (as int) and outputs your year in college as freshman, sophomore, junior, senior, or super senior
Background image of page 5

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

View Full Document Right Arrow Icon
Shorthand for if / else 6 if (n1 > n2 ) max = n1; else max = n2; max = (n1 > n2) ? n1 : n2;
Background image of page 6
Loops Loop - part of program that repeats Body - statements being repeated Iteration - each repetition of body Stopping condition 7
Background image of page 7

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

View Full Document Right Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}