初学Java 从控制台读取输入

代码 

 1 import java.util.Scanner;
 2 public class ComputeArea {
 3 public static void main(String[] args) {
 4 Scanner input = new Scanner(System.in);
 5 System.out.print("Enter a number for radius: ");
 6 double radius = input.nextDouble();
 7 double area;
 8 area = radius * radius * 3.14159;
 9 System.out.println("The area for the circle of radius " + radius + " is " + area);
10 }
11 
12 }

 

posted @ 2018-09-11 10:25  LeoLiY  阅读(1772)  评论(0编辑  收藏  举报