Question
In this project, you will write a C++ program that prompts the user for three numbers, potentially representing the lengths of the three sides of
In this project, you will write a C++ program that prompts the user for three numbers, potentially representing the lengths of the three sides of a triangle. If the numbers do not satisfy the triangle inequality, your program will display the numbers to the nearest thousandths along with a message indicating the sides of a triangle cannot be those numbers. If the numbers satisfy the triangle inequality, your program will compute and display the area and perimeter of the triangle and then determine whether or not it is acute, right or obtuse.
Definition 1. A triangle is a three-sided polygon formed by connecting three non-collinear points in a plane with line segments.
Definition 2. The triangle inequality states that the sum of the lengths of any two sides of a triangle is greater than the length of the remaining side.
Definition 3. An acute triangle is a triangle with each interior angle less than 90 . The square of its longest side is less than the sum of the squares of the other sides; that is, max2 < short21 + short22.
Definition 4. An obtuse triangle is a triangle with at one interior angle greater than 90 . The square of its longest side is greater than the sum of the squares of the other sides; that is, max2 > short21 + short22 .
Definition 5. A right triangle is a triangle with a 90 interior angle. The square of its longest side is equal to the sum of the squares of the other sides; that is max2 = short21 + short22 .
Avoid unnecessary variables and redundant test cases. Use descriptive names for all variables. The area, denoted A, and perimeter, denoted P, of a triangle are given by the following formulas, where S1, S2 and S3 are the lengths of its sides:
P = S1 + S2 + S3
P1/2 = P/2
A = sqrt( P1/2 (P1/2 S1 ) (P1/2 S2 ) (P1/2 S3 ) )
Write a C++ program that prompts the user for a three numbers. If the numbers do not satisfy the triangle inequality, the program displays them and a message indicating that they do not. If they do, the program calculates and displays the area and perimeter of the triangle and determines whether or not the triangle is acute, obtuse or right. Name the program TriangleClassifier.cpp. The end-users interaction with the program should be formatted as shown in the sample runs with the area and perimeter displayed to the nearest thousandths.
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