Reference data types in Java use of the scanner class and the random class-0509

Source: Internet
Author: User

ImportJava.util.Scanner;classDemo02 { Public Static voidMain (string[] args) {//Guide Package//create the Class objectScanner sc =NewScanner (system.in); //use this object to invoke the method inside the class//int i = Sc.nextint (); //String str = Sc.next ();Double i =sc.nextdouble (); System.out.println ("The content you entered is:" +i); }}
ImportJava.util.Scanner;classDemo04 { Public Static voidMain (string[] args) {Scanner sc=NewScanner (system.in); /*int num = Sc.nextint ();        if (num%2==0) {System.out.println ("even");        }else{System.out.println ("odd");        } if (num<60) {System.out.println ("failed");        }else if (num<=70) {System.out.println ("good");        }else if (num<=80) {System.out.println ("medium");        }else{System.out.println ("excellent"); }*/System.out.println ("Please enter"); intA =Sc.nextint (); System.out.println ("Please enter Again"); intb =Sc.nextint (); intMax = 0; Max= A>b?a:b; System.out.println ("Maximum value is:" +max); }}
ImportJava.util.Random;classDemo03 { Public Static voidMain (string[] args) {//Guide Package//Creating ObjectsRandom r =NewRandom (); //call the method and define a variable to receive        intSJS = R.nextint (10); DoubleSjxs =r.nextdouble ();        System.out.println (SJS);    System.out.println (SJXS); }}
ImportJava.util.Random;classdianming { Public Static voidMain (string[] args) {Random R=NewRandom (); intSZ = R.nextint (8); if(sz==0) {System.out.println ("Director"); }         Else if(sz==1) {System.out.println ("Rui"); }         Else if(sz==2) {System.out.println ("Wang Rongshen"); }         Else if(sz==3) {System.out.println ("Hanke"); }         Else if(sz==4) {System.out.println ("Roger"); }         Else if(sz==5) {System.out.println ("Liu Jixun"); }         Else if(sz==6) {System.out.println ("Zhang Wei"); }         Else{System.out.println ("Wei Zihao"); }         }         }
Import Java.util.Random; class szdianming {    publicstaticvoid  main (string[] args)     {         New Random ();         int i = r.nextint (8);         = {"Director", "Rui", "Wang Rongshen", "Hanke", "Roger", "Liu Jixun", "Zhang Wei", "Wei Zihao"};        System.out.println (Arr[i]);}    }

Reference data types in Java use of the scanner class and the random class-0509

Related Article

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.