Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

More Books

Students also viewed these Databases questions

Question

Identify the option that is not part of current assets

Answered: 1 week ago

Question

To solve p + 3q = 5z + tan( y - 3x)

Answered: 1 week ago

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago