java math pi_如何在java中使用math.pi
生活随笔
收集整理的這篇文章主要介紹了
java math pi_如何在java中使用math.pi
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
轉換這個公式V = 4/3πr3有問題。我使用Math.Pi和Math.pow,但這是問題開始的地方。我得到這個錯誤(每次),
‘;’ expected
此外,直徑變量不起作用。那里有錯誤嗎?
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 ");
}
}
總結
以上是生活随笔為你收集整理的java math pi_如何在java中使用math.pi的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Arduino语法详解,部分带注释(学习
- 下一篇: 开关电源的优缺点