Public void Main (String[]args) { / / Instantiate input scanner //system.in input stream New Scanner (system.in); System.out.print ("Please enter name:"); // wait for input String Strin =sc.nextline (); // What the output receives System.out.println ("The name you entered is:" + Strin); }
2. Enter the radius of the circle to calculate the circumference and area of the circle
PackageCom.hanqi.practice;ImportJava.util.Scanner; Public classCirtle { Public Static voidMain (string[] args) {//TODO Auto-generated method stubsScanner sc =NewScanner (system.in); Final DoublePI =3.14; System.out.println ("Please enter the size of the radius"); intR =Sc.nextint (); System.out.println ("The circumference of the circle is:" +2*pi*R); System.out.println ("The area of the circle is:" +pi*r*R); }}
Output results
Input and output exercises for eclipse