圆的面积

解题思路:

  通过读题可知:此题的考点是 圆的面积公式 和 DecimalFormat 的使用(重点)

具体代码

//DecimalFormat用来格式化数据   
 public static void main(String[] args) {
        Scanner input =new Scanner (System.in);
                //创建DecimalFomat对象,限制为保留7位小数的格式
        DecimalFormat df=new DecimalFormat("0.0000000");
        int r=input.nextInt();
        double s=Math.PI*r*r;
        System.out.println(df.format(s)); //对计算结果进行格式化处理
        
  }

  2020-03-27 17:47:50   

 

posted @ 2020-03-27 17:48  木原纺  阅读(188)  评论(0编辑  收藏  举报