初學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