I'm trying to write a 'simple' program that attempts to sort through the data the user has and outputs the missing variable in the pythagorean formula. I think I have the switch statements handled, assuming this is a good method and I'd be happy to learn better ones, but can't get the math to come out right. I think it has something to do with how I'm trying to square the value but I have no idea. Any advice will greatly be appreciated.
{
using std::cout;
using std::cin;
using std::string;
int casescenario;
double a;
double b;
double c;
cout << "Please examine the following options carefully\n"
<< " 1. You have both a and b value and wish to solve for c\n"
<< " 2. You have both a and c values and wish to solve for b\n"
<< " 3. You have both c and b values and wish to solve for a\n";
cin >> casescenario;
switch (casescenario)
{
case 1:
cout << "Please enter value for a\n";
cin >> a;
cout << "Please enter value for b\n";
cin >> b;
cout << (a*a) + (b*b) << " is the value for C\n";
case 2:
cout << "Please enter value for a\n";
cin >> a;
cout << "Please enter value for c\n";
cin >> c;
cout << (c*c)-(a*a) << "is the value for b!\n";
}
system ("pause");
return 0;
}
P.S.
The case scenario for option three obviously isn't completed yet but I felt like I didn't want to move onto it until I had solved the problems in case two; it seemed to me that they would repeat themselves.