import java.util.Scanner;
public class Test {
public static void main(String[] args) {
Scanner userInput = new Scanner(System.in);
final double PI = Math.PI;
final double sphereVolumeConstant = (4/3);
System.out.println("Volume of a sphere.");
System.out.print("Radius of sphere: ");
double radius = userInput.nextDouble();
double volumeOfSphere = sphereVolumeConstant * PI * Math.pow(radius, 3);
System.out.println("Volume = " + sphereVolumeConstant);
}
}
Terminal:
Volume of a sphere.
Radius of sphere: 5
Volume = 1.0
I am trying to calculate the constant itself which keeps coming out to be an integer even though it shouldn't, or at least I don't think it should. Can someone please help/explain?
(4/3)
?