gurlygurlz
January 10th, 2003, 07:47 PM
I am trying to nest if statements in my program, but it asks all of the questions even if it doesn't meet the criteria.
For Example:
cout << "Does " << patient_name<<" have a cough? ";
cin >> Q4;
if (Q4 == "yes" || "Yes")
{
cout << "Does "<< patient_name<<" have a dry cough? ";
cin >> Q4_a;
if (Q4_a == "no" || "No")
{
cout << "Does "<< patient_name<<" have a mild hacking cough? ";
cin >> Q4_b;
if (Q4_b == "no" || "No")
{
cout << "Does "<< patient_name<<" have a severe cough? ";
cin >> Q4_c;
}
}
}
Why is it asking if the user has a mild hacking cough and a severe cough if the user inputs that he already has a dry cough? I want it to prompt the user if the patient has a dry cough, and if he does I don't want it to ask if he also has a mild hacking and a severe cough.
THANKS :)
For Example:
cout << "Does " << patient_name<<" have a cough? ";
cin >> Q4;
if (Q4 == "yes" || "Yes")
{
cout << "Does "<< patient_name<<" have a dry cough? ";
cin >> Q4_a;
if (Q4_a == "no" || "No")
{
cout << "Does "<< patient_name<<" have a mild hacking cough? ";
cin >> Q4_b;
if (Q4_b == "no" || "No")
{
cout << "Does "<< patient_name<<" have a severe cough? ";
cin >> Q4_c;
}
}
}
Why is it asking if the user has a mild hacking cough and a severe cough if the user inputs that he already has a dry cough? I want it to prompt the user if the patient has a dry cough, and if he does I don't want it to ask if he also has a mild hacking and a severe cough.
THANKS :)