Created
September 7, 2018 18:25
-
-
Save haashimrehan/7b32cf52730cf48138e428a1c9d8b4bd to your computer and use it in GitHub Desktop.
Calculate the volume of three spheres
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ThreeSphereCalc{ | |
public static void main(String []args){ | |
final double PI = 3.14159265358979; | |
double radius = 10; | |
double volume = 4.0/3.0*PI*radius*radius*radius; | |
System.out.println("The sphere with a radius of "+radius+" has a volume of " + volume); | |
radius = 20; | |
volume = 4.0/3.0*PI*radius*radius*radius; | |
System.out.println("The sphere with a radius of "+radius+" has a volume of " + volume); | |
radius = 30; | |
volume = 4.0/3.0*PI*radius*radius*radius; | |
System.out.println("The sphere with a radius of "+radius+" has a volume of " + volume); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment