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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started