Assignment #10

Instructions

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

Example I/O (Input and Output)

Example #1

example input

example output

Example #2

example input

example output

Example #3

example input

example output


Click to validate the HTML code

Click to validate the CSS code