#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
usingnamespace std;
void getLegs (double&, double &);
double calcHypotenuse (double, double);
int main()
{
double length1;
double length2;
cout<<endl;
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
cout<< " Welcome to the Hypotenuse Calculator program!\n";
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
cout<<endl;
getLegs (length1, length2);
calcHypotenuse (length1,length2);
return 0;
}
// Function that prompts for and obtains the lengths of the legs of a right
// triangle from the user and 'returns' their values by reference
void getLegs(double &, double &)
{
double legOne;
double legTwo;
cout <<"Please enter the length of side 1: ";
cin>>legOne;
cout<<"Please enter the length of side 2: ";
cin>>legTwo;
}
// Function that computes and returns the hypotenuse of a right triangle,
// given the lengths of the legs
double calcHypotenuse(double legOne, double legTwo)
{
double hypotenuse;
hypotenuse = sqrt((pow(legOne, 2)) + (pow(legTwo, 2)));
cout<<setprecision(2)<<fixed<<showpoint;
cout<<"The hypotenuse of your triangle is " << hypotenuse<<endl;
return hypotenuse;
}