初学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 }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM