Create a new Java project called lab1 and a class named Lab1 Create a second class called VolumeCalculator. Add...

50.1K

Verified Solution

Question

Programming

  1. Create a new Java project called lab1 and aclass named Lab1
  1. Create a second class calledVolumeCalculator.

  1. Add a static field named PI which = 1415

  1. Add the following static methods:

  1. double static method named sphere thatreceives 1 double parameter (radius) and returnsthe volume of a sphere.

  1. double static method named cylinder thatreceives 2 double parameters (radius &height) and returns the volume of a cylinder.

  1. double static method named cube that receives1 double parameter (side) and returns the volumeof a cube.

  1. double static method named box that receives 3double parameters (length, width &height) and returns the volume of the box

  1. Back in Lab1 in the main method,
    1. Declare variables for each of the values used as parameters forthe above methods, and then give them values.

  1. Call each of the static methods inVolumeCalculator sending the appropriate variablein as a parameter.
    Print the value of the variable(s) sent and the result, withlabels. (Also, tell me which shape this volume is for.)

Answer & Explanation Solved by verified expert
3.7 Ratings (694 Votes)
import javautil public class volumeCalculator static double pi 22070 public static double spheredouble radius double vs 4030piradiusradiusradius return vs public static double cylinderdouble    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students