1 ImportJava.util.Scanner;2 Public classHelloforwhile {3 4 /**5 * Document Comment, program name: Helloforwhile Process Control Development time: 2016-03-07 Hey6 * */7 Public Static voidMain (string[] args) {8 //TODO auto-generated Method Stub9SYSTEM.OUT.PRINTLN ("Test");Ten inty = 50; One intx = 800; A BooleanZ; - //compound statements, also called block statements, are enclosed in {}. - { thez = y >x; -System.out.println ("" "1" y>x established? " +z); - } - //If statement, only one statement can omit curly braces; + if(X >y) -System.out.println ("" 2 "x greater than Y set"); + //if...else ... A if(X >y) { atSystem.out.println ("3" x greater than y! "); -}Else { -System.out.println ("" 4 "x is less than or equal to y! "); - } - //If...else If ... Multi-Branch Statements - intMath = 79; in if(Math > 90) { -System.out.println ("Math score" excellent "!) "); to}Else if(Math > 80) { +System.out.println ("Math score" good "!) "); -}Else if(Math > 60) { theSystem.out.println ("Math Score" qualified "!) "); *}Else { $System.out.println ("The Math Score" failed!) ");Panax Notoginseng } - //A multi-branch statement in which the value in a switch statement expression must be an integer or a character type. the //1.1, "OK" is illegal. + intSeason=3; ASystem.out.println ("Enter a number to represent the season bar:" +season); the Switch(season) { + Case1: -System.out.println ("Spring"); $ Break; $ Case2: -System.out.println ("Summer"); - Break; the Case3: -System.out.println ("August");Wuyi Break; the Case4: -System.out.println ("Winter"); Wu Break; - default: AboutSystem.out.print ("The value of season is not an integer of 1-4 and does not represent any season ~"); $ } - - //Problem One: Verifying the legality of login information -Scanner scan=NewScanner (system.in); ASystem.out.println ("Please enter user name:"); +String username=scan.nextline (); theSystem.out.println ("Please enter password"); -String userpw=scan.nextline (); $ if(!username.equals ("Sunshine")) {//Why this cannot be used: (Username= "Sunshine") theSystem.out.println ("Username is incorrect! "); the } the Else if(!userpw.equals ("123456")) { theSYSTEM.OUT.PRINTLN ("The password is incorrect! "); - } in Else { theSystem.out.println ("Congratulations, login successful!") "); the } About the //assign a department to a new employee the the.................................................. Continue to update ...... ..... ..................... + -}//Main the Bayi the}//Helloforwhile
No2. Learning Notes _ Process Control