/* Author : Michael Robinson Program : swithClassInt.java Purpose : To present the switch statement using char as data input. NOTE: switch does not allow for comparision evaluations ( =, >=, ,=, etc) Updated : Jan 29, 2099 */ import java.util.Scanner; public class switchClassInt { public static void switchOne() //using numbers { String label = "\n Enter your grade (70, 80, 90" + " to pass the class or 0 to exit) : "; int grade = 999; System.out.print( label ); //request input from user Scanner keyboard = new Scanner(System.in); //convert input to int data type grade = (int)keyboard.nextInt(); while( grade != 0 ) { switch(grade) //execute switch using the grade entered { case 90: //if grade = 90 System.out.println( "\n You obtained " + "grade, A range" ); break; //terminate loop case 80: //if grade = 80 System.out.println( "\n You obtained " + "grade, B range" ); break; //terminate loop case 70: //if grade = 70 System.out.println( "\n You obtained " + "grade, C range" ); break; //terminate loop default: //else System.out.print( "\n Please re-enter grade" ); }//end switch System.out.print( label ); //convert input to int data type grade = (int)keyboard.nextInt(); }//end while(grade !=0) }//end public static void switchOne() public static void main( String arg[] ) { switchOne(); System.out.println( "\n\tEnd of Program" ); }//end public static void main( String arg[] ) }//end public class switchClass