how can i make this code works?
it is supposed to give me "Unable to make a diagnosis" only when i answer the questions with characters other than 'y' or 'n', but i don't know how to do it.
can somebody tell me what's wrong?
A response will be very appreciated.
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
// NOTE - Assume that the user always provides valid input
char fever; // 'y' if the user has a fever
char stuffy; // 'y' if the user has a stuffy nose
char rash; // 'y' if the user has a rash
char earHurts; // 'y' if the user's ear hurts
cout << "Disclaimer -- This should not be used for a real medical diagnosis"
<< endl << endl;
/////////////////////////
// Start of your code
// Ask the user if he has a fever
cout << "Do you have fever? (Y/N) ";
cin >> fever;
// Ask the user if he has a stuffy nose
cout << "Do you have a stuffy nose? (Y/N) ";
cin >> stuffy;
// Ask the user if he has a rash
cout << "Do you have a rash? (Y/N) ";
cin >> rash;
// Ask the user if his ear hurts
cout << "Do your ears hurt? (Y/N) ";
cin >> earHurts;
// Using if - else if - else statments with complex conditions, make
// a diagnosis. If the user enters characters other than 'y' or 'n',
// print "Unable to make a diagnosis"
if (fever != ('Y') || ('N')) {
cout << "Unable to make a diagnosis. " << endl;
}
elseif (stuffy != ('Y') || ('N')) {
cout << "Unable to make a diagnosis. " << endl;
}
elseif (rash != ('Y') || ('N')) {
cout << "Unable to make a diagnosis. " << endl;
}
elseif (earHurts != ('Y') || ('N')) {
cout << "Unable to make a diagnosis. " << endl;
}
// End of your code
/////////////////////////
system("pause");
return 0;
}