Chapter4_2-DecisionStatements

n xx 10 10 switch n case 1 x 10 case 2

Info iconThis preview shows page 1. Sign up to view the full content.

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

Unformatted text preview: OUIR Introduction to OOP Switch With No break Statements true N == 11?? N == xx= 10; = 10; switch ( N ) { case 1: x = 10; case 2: x = 20; case 3: x = 30; false true N == 22?? N == xx= 20; = 20; false } true N == 3 ? N == 3 ? xx= 30; = 30; false Page 10 Dr. S. GANNOUNI & Dr. A. TOUIR Introduction to OOP Switch With break Statements true switch ( N ) { case 1: x = 10; N == 11?? N == false break; case 2: x = 20; break; } true N == 33?? N == Dr. S. GANNOUNI & Dr. A. TOUIR break; break; xx= 20; = 20; false false Page 11 true N == 22?? N == case 3: x = 30; break; xx= 10; = 10; break; break; xx= 30; = 30; break; break; Introduction to OOP switch With the default Block switch (ranking) { case 10: case 9: case 8: System.out.print("Master"); break; case 7: case 6: System.out.print("Journeyman"); break; case 5: case 4: System.out.print("Apprentice"); break; default: System.out.print("Input error: Invalid Data"); break; } Page 12 Dr. S. GANNOUNI & Dr. A. TOUIR Introduction to OOP...
View Full Document

Ask a homework question - tutors are online