Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Pls read the file OverLoad method.pdf and the file MyShapes Class.pdf. Write a driver program that implements the OverLoad method, with the given class defined

Pls read the file "OverLoad method.pdf" and the file "MyShapes Class.pdf". Write a driver program that implements the OverLoad method, with the given class defined for Shape.

In your driver program, insert the following line of code:

System.out.println(volume(8.500000, 7.500000));

In the box below, please enter the value printed to the command line. (JUST THE NUMBER)

image text in transcribed
image text in transcribed
public class MyShapes \{ public static int volume(int side) \{ return side * side * side; public static double volume(double radius) \{ return (double) 4/3 * Math.PI * radius radius * radius; \} public static double volume(double length, double width, \{ double height) \} return length * width * height; public static double volume(double radius, double height) \{ return Math.PI * radius * radius height; Question 5 - Overloaded methods Write a utility class called MyShapes that provides a set of overloaded class methods to calculate the volume of certain shapes. The following formulae may be useful. a) cube Write a class method called volume () that takes an integer (representing the side of a cube) and returns an integer representing the volume of the cube. b) sphere Write an overloaded class method that takes a double (representing the radius of a sphere) and returns a double representing the volume of the sphere. c) rectangular prism Write an overloaded class method that takes three doubles (representing the length and width (of the base) and the height of the prism) and returns a double representing the volume of the prism. d) cylinder Write an overloaded class method that takes two doubles (representing the radius (of the circular base) and the height of the cylinder) and returns a double representing the volume of the cylinder. e) Driver program Write a driver program that asks the user for the inputs for each figure and outputs its corresponding volume by invoking the methods from MyShapes

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications Dexa 2021 Workshops Biokdd Iwcfs Mlkgraphs Al Cares Protime Alsys 2021 Virtual Event September 27 30 2021 Proceedings

Authors: Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil ,Bernhard Moser ,Atif Mashkoor ,Johannes Sametinger ,Anna Fensel ,Jorge Martinez-Gil ,Lukas Fischer

1st Edition

ISBN: 3030871002, 978-3030871000

More Books

Students also viewed these Databases questions