Question: Write a Java program that prompts the user to enter a number representing a geometric shape. Options are 1 for square, 2 for rectangle, and

Write a Java program that prompts the user to enter a number

representing a geometric shape. Options are 1 for square, 2 for

rectangle, and 3 for right triangle. According to the user input, the

program will collect either 1, 2 or 3 values from the user

representing the lengths of the shape sides. The user is

responsible for ensuring the 3 sides of the triangle represent a

right triangle. The program will print the perimeter of the shape.

Use method overloading for the perimeter method.

Hint

Square:

perimeter = 4 x side

Rectangle:

perimeter = 2 x (side1 + side2)

Right Triangle: perimeter = side1 + side2 + hypotenuse

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!