cout << "What value would you like to solve for a, b, or c?";
float sideA, sideB, sideC;
char a, b, c;
char choice;
cin >> choice;
if (choice=='a')
//user enters a after the question which side to solve for and when the user does, it will run the if statement below, having the user input b and c.
{
cout << "Input the value of b: ";
cin >> sideB; // input the number of side b
cout << endl;
cout << "Input the value of c: ";
cin >> sideC; // input the number of side c
cout << endl;
cout << "The value of side a is equal to: " << sideA << endl << endl;
//did the <<endl<< endl just for the look of the output.
}
if (choice=='b')
//user enters b after the question which side to solve for and when the user does, it will run the if statement below, having the user input a and c.
{
cin.ignore();
cout << "Input the value of a: ";
cin >> sideA; //Input of side a
cout << endl;
cout << "Input the value of c: ";
cin >> sideC; //Input of side c
cout << endl;
cout << "The value of side b is equal to: " << sideB << endl << endl;
}
if (choice=='c')
//user enters c after the question which side to solve for and when the user does, it will run the if statement below, having the user input a and b.
{
cin.ignore();
cout << "Input the calue of a: ";
cin >> sideA; //Input of side a
cout << endl;
cout << "Input the value of b: ";
cin >> sideB; //Input of side b
cout << endl;
I think you misunderstand what "cin >> a" means, it doesn't mean that the user has input "a" but asks the user to input a value that will be stored in a.
What you want to do is store user input in a char then check what the value of that is.
For example, something along the lines of this would work:
#include <iostream>
#include <math.h>
#include <string>
usingnamespace std;
int main()
{
cout << "What value would you like to solve for a, b, or c?";
float sideA, sideB, sideC;
char a, b, c;
char choice;
cin >> choice;
if (choice=='a')
//user enters a after the question which side to solve for and when the user does, it will run the if statement below, having the user input b and c.
{
cout << "Input the value of b: ";
cin >> sideB; // input the number of side b
cout << endl;
cout << "Input the value of c: ";
cin >> sideC; // input the number of side c
cout << endl;
sideA = (sideC * sideC) - (sideB * sideB);
sideA = sqrt(sideA);
//solving for side a
cout << "The value of side a is equal to: " << sideA << endl << endl;
//did the <<endl<< endl just for the look of the output.
}
if (choice=='b')
//user enters b after the question which side to solve for and when the user does, it will run the if statement below, having the user input a and c.
{
cin.ignore();
cout << "Input the value of a: ";
cin >> sideA; //Input of side a
cout << endl;
cout << "Input the value of c: ";
cin >> sideC; //Input of side c
cout << endl;
sideB = (sideC * sideC) - (sideA * sideA);
sideB = sqrt(sideB);
//solving for side b
cout << "The value of side b is equal to: " << sideB << endl << endl;
}
if (choice=='c')
//user enters c after the question which side to solve for and when the user does, it will run the if statement below, having the user input a and b.
{
cin.ignore();
cout << "Input the calue of a: ";
cin >> sideA; //Input of side a
cout << endl;
cout << "Input the value of b: ";
cin >> sideB; //Input of side b
cout << endl;
sideC = (sideA * sideA) + (sideB * sideB);
sideC = sqrt(sideC);
//solving for side c
cout << "The value of side c is equal to: " << sideC << endl << endl;
}
}