how to use math.pi in java

前端 未结 4 1138
长情又很酷
长情又很酷 2021-02-03 19:58

I am having problems converting this formula V = 4/3 π r^3. I used Math.PI and Math.pow, but I get this error:

\';\

4条回答
  •  野性不改
    2021-02-03 20:32

    Your diameter variable won't work because you're trying to store a String into a variable that will only accept a double. In order for it to work you will need to parse it

    Ex:

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

提交回复
热议问题