import java.util.Scanner; //声明包
public class Test{ //声明类
public static void main (String[]args){//主方法
Scanner scan = new Scanner(System.in);//扫描器
System.out.println("请输入球的半径:");
double r = scan.nextDouble();//接收数据
final double PI = 3.1415926; //定义常量PI
double v = 4.0/3.0*PI*r*r*r; //公式计算
System.out.println("球的半径是:"+r); //输出半径
System.out.println("球的体积是:"+v); //输出体积
}
}
file:///C:/Documents%20and%20Settings/Administrator/Application%20Data/Tencent/Users/395417020/QQ/WinTemp/RichOle/JVRX~9%7B%60@4%7B3NDMDZKV]LPW.png
————————————————————————————————————————————————————————————————————
import java.util.Scanner; //声明包
public class Test{ //声明类
public static void main (String[]args){//主方法
Scanner scan = new Scanner(System.in);//扫描器
System.out.println("请输入球的半径:");
double r = scan.nextDouble();//接收数据
final double PI = 3.1415926; //定义常量PI
double v = 4/3*PI*r*r*r; //公式计算
System.out.println("球的半径是:"+r); //输出半径
System.out.println("球的体积是:"+v); //输出体积
}
}
[img]file:///C:/Documents%20and%20Settings/Administrator/Application%20Data/Tencent/Users/395417020/QQ/WinTemp/RichOle/4[D$%7BK7QB_UC)HM%7BQ)8MW~B.png[/img]
|
|