Question: Write a complete, compile-ready, program that will calculate the hypotenuse of a triangle given its two shorter sides. The side values must be greater than

Write a complete, compile-ready, program that will calculate the hypotenuse of a triangle given its two shorter sides. The side values must be greater than or equal to MIN and less than or equal to MAX. All values entered must be bounds checked. A welcome message should be displayed, prompting the user for the values, read in the values, bounds check the values entered, calculate the hypotenuse and show and format the output. If any of the values are out of bounds, an informative message should be output to the user and the program should exit. See examples below for output. Your program must match the output as close as possible.

Bounds Checking Output (Not all bounds errors shown)

tim@debian:~$ ./a.out Please enter the two short sides of a triangle: -1 3 Value a is smaller than MIN

tim@debian:~$ ./a.out Please enter the two short sides of a triangle: 100 20 Value a is larger than MAX

tim@debian:~$ ./a.out Please enter the two short sides of a triangle: 3 -100 Value b is smaller than MIN

Valid Output

tim@debian:~$ ./a.out Please enter the two short sides of a triangle: 4 5 The hypotenuse is ************6.4

tim@debian:~$ ./a.out Please enter the two short sides of a triangle: 4.533 6.7778 The hypotenuse is ************8.15

Blue - output from the program Red - user input Orange - calculated value

Additional instructions

  • c2 = a2 + b2
  • Some simple Algebra may be needed to calculate the hypotenuse
  • A defined constant must be used for MIN =1.0 and MAX=50
  • Value calculated is: hypotenuse
  • The output of the program must match the example as close as possible.
  • Do not include comments.
  • No cin fail error testing is required.

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!