Problem Description 根据输入的半径值,计算球的体积。  

 

Input 输入数据有多组,每组占一行,每行包括一个实数,表示球的半径。  

 

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。 Output 输出对应的球的体积,对于每组输入数据,输出一行,计算结果保留三位小数。  

 

Sample Input 1 1.5  

 

Sample Output 4.189 14.137 Hint #define PI 3.1415927           解:    
import java.text.DecimalFormat;
import java.util.Scanner;

public class Acm20190422 {

    public static void main(String[] args) throws Exception {
        Scanner input =new Scanner(System.in);
        while(input.hasNext())
        {
            double PI=3.1415927;
            double x=input.nextDouble();
            double y=((4.0/3.0)*PI*x*x*x);
            DecimalFormat df=new DecimalFormat("#.000");
            System.out.println(df.format(y));
        }
    }

}

 

 
扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄