Hello, I am sure this is not hard at all but I'm pressed for time...I believe this is good except it's performing an infinite loop. I want it to continue prompting the user to enter a day and month for their birthday as long as they enter a "y" or "Y". If they enter a "n" or "N" I want the program to cout that it can't give them a result and end the program. I think it's all right except for the validation and do-while loop syntax.
//Write using nested if/else statements.
//first validate entry.
#include <iostream>
usingnamespace std;
int main()
{
int month, day, ans = 0;
do
{
cout << "Is your birthday is between April and August? Enter N for No or Y for Yes" << endl;
cin >> ans;
cout << "If yes, this program will tell you your zodiac sign." << endl;
cout << "Enter your birth month and then the day." << endl;
cin >> month;
cin >> day;
if ((month == 3 && day >= 21) || (month == 4 && day <= 19))
{
cout << "You are Aries, Apr 1 - Apr 19." << endl;
}
elseif ((month == 4 && day >= 20) || (month == 4 && day <= 20))
{
cout << "You are Taurus, Apr 20 - May 20" << endl;
}
elseif ((month == 5 && day >= 21) || (month == 6 && day <= 21))
{
cout << "You Are an Gemini, May 21 - June 21." << endl;
}
elseif ((month == 6 && day >= 22) || (month == 7 && day <= 22))
{
cout << "You are Cancer, June 22 - July 21" << endl;
}
elseif ((month == 7 && day >= 23) || (month == 8 && day <= 22))
{
cout << "You Are an Leo, July 22 – Aug 21" << endl;
}
} while ((ans != 'y') || (ans != 'Y'));
return 0;
}
But despite the char validation, do you know why it's not recognizing the cout for the last else statement or the cout when I enter N or n. The syntax is correct when I check.
oh like a Bool ? How would I implement a bool to this?
Well, I'm not sure what you mean, but anything you put as a while condition has to be a bool expression or an expression that is implicitly convertible to bool.
But despite the char validation, do you know why it's not recognizing the cout for the last else statement or the cout when I enter N or n. The syntax is correct when I check.