Create an abstract class called Shape with the protected member String shapeName. It should have two public abstract methods getArea and getVolume. Finally, it should contain a public String method called getName which returns the shapeName. You should create a Circle class, Square class, Rectangle class, Triangle class which extend the Shape class.   Each class should contain the necessary private variables. For example, a square has a side. The area and the volume can all be derived from the side value so the only private variable necessary for the square class is the side. The circle requires a radius. The triangle requires a base, length and a height. Finally, the rectangle requires length, height and width. The classes should also contain constructors and appropriate implementations of the two abstract methods getArea and the getVolume.   **Shape Calculator** Enter 1 for a Circle Enter 2 for a Square Enter 3 for a Rectangle Enter 4 for a Triangle Enter 5 to Exit  You should use a menu with a case/switch statement that allows the user to choose which shape they want. After the user enters their choice, ask them to enter the necessary information, perform the calculations and display the area and volume for the shape the user chose. The program should continue to allow the user to choose shapes and display the results until the user enters 5 to exit.  Triangle volume: length * base * height/3  Triangle area: base * height/2 Circle area: Math.PI * radius * radius Circle volume: 4/3 * Math.PI * radius * radius * radius Square area: side * side Square volume: side * side * side Rectangle area: length * width Rectangle volume: length * width * height  Be sure to verify the user enters positive numbers and limit the display to 2 decimals.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Create an abstract class called Shape with the protected member String shapeName. It should have two public abstract methods getArea and getVolume. Finally, it should contain a public String method called getName which returns the shapeName. You should create a Circle class, Square class, Rectangle class, Triangle class which extend the Shape class. 
 
Each class should contain the necessary private variables. For example, a square has a side. The area and the volume can all be derived from the side value so the only private variable necessary for the square class is the side. The circle requires a radius. The triangle requires a base, length and a height. Finally, the rectangle requires length, height and width. The classes should also contain constructors and appropriate implementations of the two abstract methods getArea and the getVolume. 
 
**Shape Calculator** Enter 1 for a Circle Enter 2 for a Square Enter 3 for a Rectangle Enter 4 for a Triangle Enter 5 to Exit
 
You should use a menu with a case/switch statement that allows the user to choose which shape they want. After the user enters their choice, ask them to enter the necessary information, perform the calculations and display the area and volume for the shape the user chose. The program should continue to allow the user to choose shapes and display the results until the user enters 5 to exit.
 
Triangle volume: length * base * height/3  Triangle area: base * height/2 Circle area: Math.PI * radius * radius Circle volume: 4/3 * Math.PI * radius * radius * radius Square area: side * side Square volume: side * side * side Rectangle area: length * width Rectangle volume: length * width * height
 
Be sure to verify the user enters positive numbers and limit the display to 2 decimals.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education