Mam problemy z konwersją tej formuły V = 4/3 π r3
. Użyłem Math.Pi
i Math.pow
, ale tutaj zaczyna się problem. Otrzymuję ten błąd (za każdym razem),Jak korzystać z math.pi w java
"; ' oczekiwany
Również zmienna średnicy nie działa. Czy jest tam błąd?
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 ");
}
}
Kolejnym problemem natkniesz się tu odpowiedzi: http://stackoverflow.com/questions/10455677/division-in-java –