Question: 1. Write a Java application that asks the user for the lengths of all three sides of a triangle. Store each length in a variable.

1. Write a Java application that asks the user for the lengths of all three sides of a triangle. Store each length in a variable. Then calculate the perimeter of the triangle.

2. Check whether or not the three side lengths can form a real triangle. Remember that, in any real triangle, the sum of the lengths of any two sides is greater than the length of the third side. So, if the triangle has side lengths a, b, and c, then all of the following must be true:

a+b > c

a+c > b

b+c > a

If the sides given cannot make a real triangle, say so instead of saying the perimeter and terminate the program.

What kind of triangle?

1. Add code to your program to determine and say whether or not the triangle described is a right triangle. If the triangle has side lengths a, b, and c, then the triangle is a right triangle if the following is true:

a2 + b2 = c2

5 Points Extra Credit:

2. Add code to your program to determine which type of triangle has the side lengths given. A triangle can be one of the following three types:

Triangle type

Description

Equilateral

All three side lengths equal

Isosceles

Two side lengths equal, one different

Scalene

All three side lengths different

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!