例题:求圆的面积

 

String.format("%.7f", s)的用法

 

import java.util.Scanner;
public class Main {
   public static void main(String[] args){

       Scanner sc= new Scanner(System.in);
       int r=sc.nextInt();


       double PI=3.14159265358979323;   //圆周率
       double s=PI*r*r;   //面积
       System.out.println(String.format("%.7f", s));   //结果保留七位小数

      }
}

 

println()    输出后换行
print() 输出后不换行

 

相关文章:

  • 2021-09-08
  • 2022-12-23
  • 2021-12-18
  • 2021-12-18
  • 2021-08-21
  • 2022-02-27
猜你喜欢
  • 2022-02-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-18
  • 2022-12-23
相关资源
相似解决方案