返回列表 發帖
  1. public class tqc109
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         int r=(int)(Math.random()*100)+1;
  6.         double area=r*r*Math.PI;
  7.         double vol=r*r*r*Math.PI*4/3;
  8.         System.out.printf("隨機產生的半徑為: "+r+"%n%n");
  9.         System.out.printf("計算後,直徑為: "+(r*2)+"%n%n");
  10.         System.out.printf("計算後,圓面積為: "+area+"%n");
  11.         System.out.printf("四捨五入至小數第1位,則圓面積為: %.1f%n%n",area);
  12.         System.out.printf("計算後,圓體積為: "+vol+"%n");
  13.         System.out.printf("四捨五入至小數第1位,則圓體積為: %.1f%n%n",vol);
  14.     }
  15. }
複製代碼

TOP

返回列表