1 PackageKaoshi;2 /*3 * Student Status Enquiry4 * @ Longing for life5 * @ time: 2017, 3, 76 */7 ImportJava.util.Scanner;8 9 Public classStudentstate {Ten Public Static voidMain (string[] args) { One Booleanflag=false; A while(true){ -Scanner scan=NewScanner (system.in); -System.out.print ("Please enter the first English letter of the learner status:"); theString input =scan.nextline (). toUpperCase (); - CharCHR = Input.tochararray () [0]; - Switch(CHR) { - CaseE: +System.out.println ("excellent"); -flag=enquire (flag); + Break; A CaseG: atSystem.out.println ("Good"); - -flag=enquire (flag); - Break; - CaseS: -System.out.println ("Medium"); inflag=enquire (flag); - Break; to CaseF: +System.out.println ("Unqualified"); -flag=enquire (flag); the Break; * $ default:Panax NotoginsengSYSTEM.OUT.PRINTLN ("Input error, unable to convert"); -flag=enquire (flag); the Break; + } A if(flag==true){ theSystem.out.println ("Exit System!")); +System.exit (-1); - } $ } $ } - /* - * Select whether you want to continue querying the */ - Public Static BooleanEnquire (Booleanflag) {Wuyi while(true){ theScanner scan=NewScanner (system.in); -System.out.print ("\t\n"); WuSystem.out.print ("Do you want to continue?") (y/n) "); -String INPUT6 =scan.nextline (); AboutSystem.out.print ("\t\n"); $INPUT6 =input6.touppercase (); - CharCHR6 = Input6.tochararray () [0]; - if(chr6== ' N '){ -flag=true; A returnFlag; + } the Else if(chr6== ' Y '){ - returnFlag; $ } the Else{ theSYSTEM.OUT.PRINTLN ("Input error, re-enter!") "); the } the } - } in}
Java Basics: Student status queries