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