计算球体积

计算球体积

时间限制:3000 ms  |  内存限制:65535 KB
难度:1
 
描述
根据输入的半径值,计算球的体积。
 
输入
输入数据有多组,每组占一行,每行包括一个实数,表示球的半径。(0<R<100)
输出
输出对应的球的体积,对于每组输入数据,输出一行,计算结果四舍五入为整数
Hint:PI=3.1415926
样例输入
1
1.5
样例输出
4
14

code:
package acmjihe;

import java.util.Scanner;

public class Main {

	private static final double PI=3.1415926;
	
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		while (input.hasNext()) {
			double R = input.nextDouble();
			double TI = 4.0*PI*R*R*R/3;
			System.out.println(Math.round(TI));
		}
		input.close();
	}
	
}

  

原文地址:https://www.cnblogs.com/airycode/p/5554274.html