/* Author : Michael Robinson Program : swithClassChar.java Purpose : To present the switch statement using char as data input and add char input using +=. NOTE: switch does not allow for comparision evaluations ( =, >=, ,=, etc) Updated : Jan 29, 2099 */ import java.util.Scanner; public class switchClassChar { public static void switchTwo() { //using chars, leaving break out until the last case to show //what happens Scanner sc = new Scanner(System.in); System.out.print( "Enter your program grade: " ); String s = sc.next(); //request input from user char p = s.charAt(0); //convert input to char data type String details = ""; switch(p) { case 'F': //if p == 'F' case 'f': //if p == 'f' details += "F"; break; //terminate loop case 'D': //if p == 'D' case 'd': //if p == 'd' details += "D"; break; //terminate loop case 'C': //if p == 'C' case 'c': //if p == 'c' details += "C"; break; //terminate loop case 'B': //if p == 'B' case 'b': //if p == 'b' details += "B"; break; //terminate loop case 'A': //if p == 'A' case 'a': //if p == 'a' details += "A"; break; //terminate loop default: details = s; break; //terminate loop } System.out.println( "\nNice work on getting " + details + " on your First program" ); }//end public static void switchTwo() public static void main( String arg[] ) { switchTwo(); System.out.println( "\n\tEnd of Program" ); }//end public static void main( String arg[] ) }//end public class switchClassChar