No2. Learning Notes _ Process Control

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.