Methods & Return Values Assignment

See this link for Assignment Policies, Submission Instructions, and Grading Guidelines.

Instructions

1.      Write a Java application that does the following:

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. 

4.      IMPORTANT NOTE: Create a 2nd class in the same file as your LastNameFirstNameX class with 3 static methods to do the calculations. Your 3 static methods should have BOTH parameters & return values. The 2nd class should NOT have the keyword “pubic” in front of it.

5.      Use the number as the diameter (not the radius) of the sphere, as the side of the cube, and as the side of the regular tetrahedron.

6.      As much as possible, use the static methods & variables of class Math to do your calculations.

7.      Use only one (1) JOptionPane window to output the volume of the three shapes. Use the newline character ("\n") to do this.

8.      Formulas: Volume of a cube = s3; Volume of a regular tetrahedron = 1/12 r3 √2; Volume of a sphere = 4/3 π r3 (radius = diameter / 2).

9.      Example I/O: If the number is 10, then the results should be cube = 1000, regular tetrahedron = 117.85113019775792073347406035081, sphere = 523.59877559829887307710723054658

10.  Don’t forget to use try-catch blocks, so that your program cannot crash.

 

 

 

© 2007 William Albritton