Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Step: 3

blur-text-image

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

Data Analysis Using SQL And Excel

Authors: Gordon S Linoff

2nd Edition

111902143X, 9781119021438

More Books

Students also viewed these Databases questions