Java code example (2)

Source: Internet
Author: User

/** * Purpose: to ask you and * @author Chenyanlong * Time: 2017/10/14 */package Com.hp.test02;import java.util.scanner;public class HS_Luck ynumsum {public static void main (string[] args) {//TODO auto-generated method Stubint num;        System.out.println ("Please enter 4-digit membership card number:");                Scanner input=new Scanner (system.in);        Num=input.nextint ();        SYSTEM.OUT.PRINTLN ("Membership card number is:" +num);                       System.out.println ("Thousand:" +num/1000);        System.out.println ("Hundred:" +num/100%10);        System.out.println ("10-bit:" +num/10%10);        System.out.println ("digit:" +num%10);                int  sum=num/1000+num/100%10+num/10%10+num%10;                SYSTEM.OUT.PRINTLN ("Membership card number" +num+ "Everyone's sum:" +sum);}

  

1 /**2 * Purpose: Print resume information on the console3  * @authorChenyanlong4 * Time: 2017/10/145  */6  Packagecom.hp.test02;7 8  Public classHs_showmessage {9 Ten      Public Static voidMain (string[] args) { One         //TODO auto-generated Method Stub AString name= "Black Stone"; -         intAge=22; -         CharSex= ' man '; theString position= "Java Engineer"; -          -System.out.println ("Name:" +name); -System.out.println ("Age:" +Age ); +System.out.println ("Gender:" +sex); -System.out.print ("Position:" +position); +  A     } at}
1 /**2 * Purpose: Basic usage of scanner3  * @authorChenyanlong4 * Time: 2017/10/145  */6  Packagecom.hp.test02;7 8 ImportJava.util.Scanner;//imported Scanner class9 Ten  Public classHs_typechange { One  A      Public Static voidMain (string[] args) { -         //TODO auto-generated Method Stub -       intNumber//Membership card Number theSystem.out.println ("Please enter the card number"); -        -Scanner input=NewScanner (system.in);//system.in system Keyboard Input -Number=input.nextint (); +SYSTEM.OUT.PRINTLN ("Membership card number:" +Number ); -     } +  A}

Java code example (2)

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.