Pythagorean Theorem Program Comment, criticize, or whatever
Code:
#include <iostream>
#include <cmath>
#include <string>
int main()
{
double SideA, SideB, SideC, Hyp; // Hyp is the Hypotenuse
std::string GetInfo;
std::cout << "The Pythagorean Theorem \n\n";
std::cout << "Do you know the hypotenuse? \n>";
std::cin >> GetInfo;
std::cout << std::endl;
std::cin.sync();
if ( GetInfo == "no" ) {
std::cout << "Enter Your Sides: \n";
std::cout << "1st: ";
std::cin >> SideA;
std::cout << "2nd: ";
std::cin >> SideB;
std::cin.ignore();
Hyp = sqrt( pow( SideA, 2) + pow( SideB, 2));
std::cout << "Hypotenuse = " << Hyp << std::endl;
} else if ( GetInfo == "yes" ) {
std::cout << "Enter Your Data: \n";
std::cout << "Hypotenuse: ";
std::cin >> SideC;
std::cout << "Side: ";
std::cin >> SideA;
std::cin.ignore();
if ( SideC < SideA )
{
std::cerr << "ERROR: The sides can't be bigger then the hypotenuse. \n";
return EXIT_FAILURE;
}
SideB = sqrt( pow( SideC, 2) - pow( SideA, 2) );
std::cout << "Missing side = " << SideB << std::endl;
} else if ( GetInfo != "no" || GetInfo != "yes" ) {
std::cout << "ERROR: Case Sensitive or Spelling \n";
return EXIT_FAILURE;
}
std::cin.get();
return(0);
}
Any advice would be appreciated and I thank you in advance.