返回列表 發帖
  1. public class jva109{
  2.         public static void main(String arg[])
  3.         {
  4.         int r=(int)(Math.random()*100)+1;
  5.        
  6.         System.out.printf("隨機產生的半徑為:%d\n\n",r);
  7.         System.out.printf("計算後,直徑為:%d\n\n",r*2);
  8.        
  9.         System.out.printf("計算後,圓面積為:%f\n",r*r*Math.PI);
  10.         System.out.printf("四捨五入至小數第1位,則圓面積為:%.1f\n\n",r*r*Math.PI);
  11.        
  12.         System.out.printf("計算後,圓體積為:%f\n",r*r*Math.PI*4/3);
  13.         System.out.printf("四捨五入至小數第1位,則圓體積為:%.1f",r*r*Math.PI*4/3);
  14.        
  15.        
  16.        
  17.        
  18.        
  19.         }
  20. }
複製代碼
附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊
水桶小鄭,鯰魚

TOP

返回列表