Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MUST BE DONE IN RAPTOR Area of Shapes Design a superclass called Shape that contains two functionsgetVolume() and getInput(). The getVolume and getInput functions in

MUST BE DONE IN RAPTOR

Area of Shapes

Design a superclass called Shape that contains two functionsgetVolume() and getInput(). The getVolume and getInput functions in the Shape class will simply return 0, you will derive from them in your subclasses mentioned below. Define 3 subclasses of the Shape classSphere, Cube, and Cone. The sphere class will need a radius field, the cube class will need a length field, and the cone class will need radius and height fields. Declare all of the appropriate setters and getters for each of these classes. The sphere class will calculate its volume as 4/3 * PI * r * r * r. The cubes volume is length * length * length. The cones volume is PI * radius * radius * height/3. Override the getInput method for each subclass so it will prompt the user to input the dimensions for each shape. Then, override the getVolume method in each subclass so it will calculate and return the volume of the shape.

Demonstrate your classes be writing a menu driven program that allows the user to select which shape they want to create. After making their selection, the program will call getInput on the object to ask the user to input the appropriate dimensions for that shape. The program should then display the volume for that shape. The menu will continue to display until the user chooses to quit.

Example Output: Please select an option: 1) Volume of a sphere 2) Volume of a cube 3) Volume of a cone 4) Quit Enter your selection: 2 [Enter] Enter the cube length: 10 [Enter] The Volume for your cube is 1000

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

Records And Database Management

Authors: Jeffrey R Stewart Ed D, Judith S Greene, Judith A Hickey

4th Edition

0070614741, 9780070614741

More Books

Students also viewed these Databases questions

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago