Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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. Bonus Extend the analysis of the triangle to identify it as equilateral, isosceles, scalene, or right. Refer to this Wikipedia article for background information: http://en.wikipedia.org/wiki/Triangle

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions

Question

3. Explain the forces that influence how people handle conflict

Answered: 1 week ago