back back back to the days of nineth grade geometry, when you may have been learning about advcanced Pythagorans theorem. Remember when you couldn't just give the square root of the hypotenuse(a^2 + b^2 = c^2 and then sqrt(c^2) is the hypotenuse) because it "wasn't exact". Well, some of you may have had to simplify the hypotenuse into the simplest root form, like a triangle with sides of 4, leaving you with 16 + 16 =32, but having to simplify 32 into "root 2*16| root 2 * root 16 | or 2root4. now, if this still makes sence and by some merical I can type coherently this late, does anyone have any ideas, or thoughts on making this into a program? I have everything up until I have to simplify 32 into 2 root 4. I was thinking maybe trying to devide ever perfect square into 32 that's <32, but I'm sure there's an easyer way. if anyone can help, I'd appreciate it alot, thanks.
the code I have so far:
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
double
cout << "1 for hypotenuse, 2 for a leg";
cin >>h;
if (h == 1)
{
cout <<"\nenter the length of one leg, then the other.";
cin >>l1>>l2;
a = pow(l1, 2);
b = pow(l2, 2);
c = a + b;
d = sqrt(c);
cout <<"\nhypotenuse = "<<c<<" or rooted, "<<d<<endl;
ya... ya... not much, but here's a program I worked out that kinda works, may be usefll for those studying the topic:
#include <iostream>
#include <math.h>
#include <conio.h>
using namespace std;
int main()
{
double a, b, c, d, e, f, z;
int i;
cout << "This program is to be used to figure out the side of a right triangle using Pythagoran's Theorum. if you want to know the background of pythagoran's theorum, type 3"<<endl;
for (;;)
{
cout << "To find out the length of the hypotenuse, press 1, and to find the length of a leg, press 2, to check to see if a triangle is right, press 3, for help, type 5 and to exit, press 9."<<endl;
cin >>i;
switch (i)
{
case 5:
cout << "basicly Pythags Theorum is used tyo find the length of the hypotenuse, or leg of a right triangle, and only a right triangle. Incidently, since it;s only used to find out a right triangle, you can use it to find out if the triangle in question is square or not if you have the length of the two sides. The theorum finds out the length of a side using the fromula a^2 + b^3 = c^2(for the hypotenuse), or c^3 - b^2 = a^2. Then after you have the answer, you square root it to get the side. This program does this very fast and easily.\n\n\n"<<endl;
break;
case 9:
return 0;
case 1:
cout << "Please enter the length of one side, then the other."<<endl;
cin >>a>>b;
c = pow(a, 2);
d = pow(b, 2);
e = c + d;
f = sqrt(e);
cout << "the length of the hypotenuse is " <<f<<"\n\n\n";
break;
case 2:
cout << "Please enter the length of one side, then the hypotenuse "<<endl;
cin >>a>>b;
c = pow(a, 2);
d = pow(b, 2);
e = d - c;
f = sqrt(e);
cout << "the length of the missing side is " <<f<<"\n\n\n";
break;
case 3:
cout << "please enter the length of two sides " <<endl;
cin >>a>>b;
c = pow(a, 2);
d = pow(b, 2);
e = d + c;
f = sqrt(e);
cout << "\nNow, please enter the length of the hypotenuse ";
cin >>z;
if (z == f)
cout <<"yes, the triangle is a right triangle\n\n\n";
else if (z < f)
cout << "Nope, you've got yourslef an acute triangle\n\n\n";
else if (z > f)
cout << "Nope, you've got yourself an obtuse triangle\n\n\n";
break;
default:
cout <<"please enter a valid entry"<<endl;
}
}
return 0;
}