Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using C++ , Write an inline function called FindHypotenuse() that accepts the le

ID: 3857610 • Letter: U

Question

Using C++ ,

Write an inline function called FindHypotenuse() that accepts the lengths of two sides of a right triangle as parameters. The function should then return the length of the hypotenuse side. Use Pythagorean Theorem (c2 = a2 + b2). This function should only handle processing. Input and output to the console should not be in this function.

Include the function in a working program which separately prompts the user for the two sides, validates the input of each side as numeric, calls the function to calculate the hypotenuse, and then displays the hypotenuse to three decimal places. For the purpose of numeric validation, include the MyInputValidation.h custom header file. The minimum allowable value of a side is -100.0 and the maximum allowable value is 100.0. ( ****** PLEASE HELP ****** AND PLEASE MAKE SURE IT DOES NOT ACCEPT MORE THAN 100 TO -100)

Please enter the first side of the triangle:-55 Please enter the second side of the triangle: 62 The hypotenuse is: 82.879 Press any key to continue

Explanation / Answer

#include <iostream>
#include <cmath>
using namespace std;

inline double FindHypotenuse(double x, double y) //inline fuction
{
return (sqrt(x*x + y*y)); //returning the length
}

int main( )
{
double a,b; //varialbe decalration
do
{
cout << "Please Enter the first side of the triangle :"<<endl; //accepting values from user
cin>>a;
cout << "Please Enter the second side of the triangle :"<<endl;
cin>>b;
cout << "The hypotenuse : " << FindHypotenuse(a,b) << endl; //calling the inline function and displaying result
}while(a>100 || a<-100 || b>100 || b<-100);
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote