Assignment #10
Instructions
-
Write a Java application that does the following:
-
Build your program from this starter code: LastNameFirstName10.java
and MyProgram.java
-
Use a JOptionPane window to ask the user to enter a number.
-
Use the number to calculate the volume (NOT the area) of three shapes: a sphere, a regular tetrahedron, and a cube,
with three (3) static methods which are defined in the MyProgram.java file.
-
The three (3) static method definitions should have one parameter for the side,
and a return value, which is the volume.
-
Calculate the volume inside each static method definition.
-
Use the number as the side of the cube, as the side of the regular tetrahedron, and as the radius of the sphere.
-
As much as possible, use the static methods and variables of class Math to do your calculations.
-
Use only one (1) JOptionPane window to output the volume of the three shapes. Use the newline character ("\n") to do this.
-
Formulas:
Volume of a cube = side3
Volume of a regular tetrahedron = 1/12 side3 √2
Volume of a sphere = 4/3 π radius3
-
Use try-catch blocks to catch any exceptions, such as NumberFormatException and NullPointerException.
-
Don't forget to include Java documentation (javadoc) comments in your program.
See the Java Coding Standard for details.
-
** Make sure to write Java documentation (javadoc) comments above each method in your progam! **
-
See the syllabus for the Assignment Grading Guidelines for your program assignments.
Example I/O (Input and Output)
Example #1
Example #2
Example #3
Click to validate the HTML code
Click to validate the CSS code