Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Students also viewed these Databases questions