1. Engineering
  2. Computer Science
  3. design develop and test a c program that prompts the...

Question: design develop and test a c program that prompts the...

Question details

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 in any order. • Identify the longest side as the apparent hypotenuse. • If the sum of the lengths of the shorter sides is less than the length of the longest side, declare the sides to be “Not a Triangle”, and ask the user to re-enter all three side lengths. • Calculate the expected length of the hypotenuse based on the lengths of the 2 shorter sides. • Compare the expected length of the hypotenuse to the length input by the user. • 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, calculated hypotenuse length, and result of the comparison. Coding • Validate all inputs and do not proceed until valid values are entered. • Do not accept input values less than 0.1 inches or greater than 100.0 inches. • For the purposes of this assignment, “the same” means with a numerical difference less than or equal to 0.0001. • 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.

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution