Question: Exam 2 Programming Exercise Write a small program that will calculate the area of shapes. Write a Class Shape. That class should have the double
Exam 2 Programming Exercise
Write a small program that will calculate the area of shapes.
Write a Class Shape. That class should have the double attribute area.
Then write three sub-classes from Shape: Circle, Rectangle, and Square.
The sub-classes should have the required attributes to calculate the respective areas:
Circle has a double attribute radius, Rectangle has a double attribute sideA and sideB, and Square has a double attribute side.
In the main program, ask the user which shape they want to calculate: 1, 2, or 3, for Circle, Rectangle, and Square. Based on the input, ask for the attribute required to calculate the shape.
Once the user has entered the required information, output the area of the shape, and ask the user if they want to calculate another shape.
Java
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
