07-feb06

07-feb06 - COMP110 SwitchStatementsandLoops TabithaPeckM.S....

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 DocumentRight 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 DocumentRight 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 DocumentRight 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 DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/02/2009 for the course COMP 110 taught by Professor Stotts during the Spring '08 term at UNC.

Page1 / 20

07-feb06 - COMP110 SwitchStatementsandLoops TabithaPeckM.S....

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

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