小编Iva*_*ork的帖子

如何在java中使用math.pi

我在转换这个公式时遇到了问题V = 4/3 ? r^3.我用Math.PIMath.pow,但是这是问题的开始位置.我得到这个错误(每次),

';' 预期

此外,直径变量不起作用.那里有错误吗?

import java.util.Scanner;

import javax.swing.JOptionPane;

public class NumericTypes    
{
    public static void main (String [] args)
    {
        double radius;
        double volume;
        double diameter;

        diameter = JOptionPane.showInputDialog("enter the diameter of a sphere.");

        radius = diameter / 2;

        volume = (4 / 3) Math.PI * Math.pow(radius, 3);

        JOptionPane.showMessageDialog("The radius for the sphere is "+ radius
+ "and the volume of the sphere is ");
    }
}
Run Code Online (Sandbox Code Playgroud)

java pi

29
推荐指数
1
解决办法
40万
查看次数

标签 统计

java ×1

pi ×1