This program is supposed to let the user input three numbers, rearrange them in increasing order, and identify the properties of the triangle.
For some reason the program works like a beauty, until it hits isRig. It doesn't display anything for isRig's answer. I'm boggled. I looked it over 5 or 6 times, but I'm just starting so I can't find anything. Or maybe im just blind.
Thank you!
Code:
//Included Files
#include <iostream>
using namespace std;
//Function Prototypes
bool isTri(float, float, float);
bool isIso(float, float, float);
bool isEqu(float, float, float);
bool isAcu(float, float, float);
bool isRig(float, float, float);
bool isObt(float, float, float);
//Main Function
int main() {
//Variable Declarations
float x,y,z;
//Inputs
cout << " Please enter the triangle lengths: "<<endl;
cout << " Length 1: ";
cin >> x;
cout << " Length 2: ";
cin >> y;
cout << " Length 3: ";
cin >> z;
//Answers
cout<<"The triangle is: ";
if (isTri(x,y,z))
{
if (isIso(x,y,z))
{
cout << "Isoceles ";
}
if (isEqu(x,y,z))
{
cout << "Equilateral ";
}
if (isAcu(x,y,z))
{
cout << "Acute ";
}
if (isRig(x,y,z))
{
cout << "Right ";
}
if (isObt(x,y,z))
{
cout << "Obtuse ";
}
}
else
{
cout <<"illegal ";
}
cout<<endl;
return 0; }
//isTriangle
bool isTri(float x,float y,float z)
{
if (x > 0 && ((x + y) > z))
return true;
else
return false;
}
//isIso
bool isIso(float x,float y,float z)
{
if (x == y || y == z)
return true;
else
return false;
}
//isEqu
bool isEqu(float x,float y, float z)
{
if (x == y && y == z)
return true;
else
return false;
}
//isAcu
bool isAcu(float x,float y, float z)
{
if ((x*x)+(y*y)>(z*z))
return true;
else
return false;
}
//isRig
bool isRig(float x,float y, float z)
{
if ((x+x)*(y*y) == (z*z))
return true;
else
return false;
}
//isObt
bool isObt(float x,float y,float z)
{
if ((x+x)*(y*y) < (z*z))
return true;
else
return false;
}