CS 211
Programming Assignment #1
note change of due date
Due Wednesday, February 24 at class time
Program
Write a Java program named SphereCalculations that generates a random value for the radius of a sphere and prints
the sphere's volume and surface area. Use the formulas below, where r represents the radius of the sphere:
- Volume = 4/3 PI r^3
- Surface Area = 4 PI r^2
Your program must satisfy the following requirements:
- import and use class Random to create a random number generator object.
- radius r must be an int value in the range 1 .. 10
- use Math.pow() to compute r^3 and r^2
- print the output to four decimal places. Use class DecimalFormat to format the output.
Sample Execution:
For a sphere with radius: 2
Volume: 33.5103
Surface area: 50.2655
Links to Java docs that are useful for this assignment:
Submit:
- a copy of SphereCalculations.java. Submit to Blackboard; if Blackboard problems have not been fixed, we will
make other arrangements.
- in file SphereCalculations.java, clearly list the parts of the assignment (if any) that are incomplete or that are known to be incorrect.