Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem: Given the lengths of the three sides of a triangle, determine whether the triangle is a Right Triangle or not. Your assignment: Design, develop
Problem: Given the lengths of the three sides of a triangle, determine whether the triangle is a Right Triangle or not. Your assignment: Design, develop and test a C++ program that prompts the user to enter the lengths of three sides of a triangle and then outputs a message indicating whether the triangle is a right triangle or not. Discussion: In a right triangle, the square of the length of the longest side (the hypotenuse) is equal to the sum of the squares of the lengths of the two shorter sides. Use the following steps to complete the assignment. Input three values representing the lengths of three sides of a triangle. Assume the units for these lengths to be inches. The program must accept these values in any order - entering the longest value first, second, or last must not affect the operation of the program. Identify the longest side as the apparent hypotenuse. If the sum of the lengths of the two shorter sides is less than the length of the longest side, declare the sides to be "Not a Triangle", and require the user to re-enter all three side lengths. Calculate the expected length of the hypotenuse based on the lengths of the two shorter sides. Compare the expected length of the hypotenuse to the length of the apparent hypotenuse. If the two lengths are "the same", declare the triangle to be "Right". Otherwise, declare the triangle to be "Not Right". Display the input values, apparent hypotenuse length, expected hypotenuse length, and result of the comparison. Coding Do not accept any input value less than 0.1 inches or greater than 100.0 inches. Validate each side length as it is entered, and do not proceed to the next side till the current one is validated. Do not require the side lengths to be entered in any particular order, e.g. longest side last. Your program must examine all three input values, after they have been validated, to identify the longest side. For the purposes of this assignment, "the same" means having a numerical difference less than or equal to 0.001 inches. Suggestion: develop a function to determine whether two input parameters are "the same" or not, returning a Boolean result. Use any programming techniques that you are comfortable with. You are not restricted to just those techniques covered in the introductory C++ course. Format your source code according to the style guide presented in class
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