Created
September 11, 2018 18:34
-
-
Save haashimrehan/a480cbc3e803370a2cf4e593a8011188 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 VolumeCalc { | |
public static void main(String []args){ | |
// Declare Variables | |
double radius = 10; | |
double volume = 0; | |
//While the radius is less than 200 | |
//update radius value | |
while(radius <= 2000){ | |
//Calculate volume | |
volume = 4.0/3.0 * Math.PI * Math.pow(radius, 3); | |
//Output to screen | |
System.out.println("The volume of a sphere with a radius of " + radius + " is " + volume); | |
//add 10 to the radius | |
radius += 0.00001; | |
if (volume > 10000) { | |
break; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment