switch (y) { case 0 : System.out.print('1'); break; case 1 : System.out.print(x); break; case 2 : System.out.print( x * x); break; case 3 : System.out.print( x * x * x ); break; case 4 : System.out.print( x * x * x * x); break; default : System.out.print("No match exists."); } |
switch (LetterGrade) { case 'a' : case 'A' : System.out.print( "Excellent"); break; case 'b' : case 'B' : System.out.print("Superior"); break; case 'C' : case 'c' : System.out.print("Average"); break; case 'd' : case 'D' : System.out.print(" Poor"); break; case 'f' : case 'F' : System.out.print( " Try again"); break; default : System.out.print("This is not a recognized letter grade."); } |
switch (What) { case 'c' : case 'C' : System.out.print(" Bobo "); case 'y' : case 'P' : System.out.print(" Is a Dog "); break; case 'x' : case 'X' : System.out.print(" Try But "); case 'z' : case 'Z' : System.out.print(" Cannot"); default : System.out.print(" Help You."); } |
if (Year == 1) System.out.print(" Freshman "); else if (Year == 2) System.out.print(" Sophomore "); else if (Year == 3) System.out.print(" Junior "); else if (Year == 4) System.out.print(" Senior "); else System.out.print(" Graduate "); |
switch (x) { case 2 : case 4 : case 6 : switch (y) { case 1: case 2: case 3: x = x + y; break; case -1: case -2: case -3: x = x - y; break; } break; case 1 : case 3: case 5 : switch (y) { case 2: case 4: case 6: x = x * y; break; case -1: case -4: case -6: x = y * y; break; } break; } System.out.print("x = " + x ); System.out.print("y = " + y); |