Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Help with Home Work (if else statements)

This is what ive written thus far. Can somebody explain how to incorporate if else statements into my program so that it will both identify the correct horoscope by the date and identify a date that falls within two days of the next sign (cusp)??? Ive created the if statements to weed out any incorrect dates entered but im unsure on how to identify the horroscopes.

For example // (jan/22 through Dec/21) is bla bla bla.

How could you declare that?

#include
using namespace std;

int main()

{
int month, day;

cout << "Enter birth month (Invalid month will end program): ";
cin >> month;

while (month>=1&&month<=12)
{
do
{
cout << "Enter your birth day (Invalid month will end program): ";
cin >> day;

switch(month)
{
case 1:
cout << "Capicorn Dec. 22 - Jan. 19: You will recieve numerous gifts from"
" somebody this month.
";
case 3:
cout << "Pisces Feb. 19 - Mar. 20: You will meet somebody special this "
"month have a nice cold beverage and tell them how much you care.
";
case 5:
cout << "Taurus Apr. 20 - May. 20: Gather your family and plan a vacation"
" to the beach.
";
case 7:
cout << "Cancer June. 22 - July. 22: Be careful when playing with matches"
" there is a good chance you could get burned this month.
";
case 8:
cout << "Leo July. 23 - Aug. 22: Play the lottery on Aug 29th chances"
" are good that you will become a millionaire.
";
case 10:
cout << "Libra Sep. 23 - Oct. 22: Take this chance to get to know your"
" co-workers, introduce them to your world.
";
case 12:
cout << "Sagittarius Nov. 22 - Dec. 21: You are bound to gain 10 pounds"
" if you are not carefull.
";

if (day < 1 || day > 31)
{
cout<< "the day you entered is not valid for the month.
";
day = 0;
}
break;

case 4:
cout << "Aries Mar. 21 - Apr. 19: The luck of the Irish is upon you, "
" plan a trip to Vegas, your bound to win this month.
";
case 6:
cout << "Gemini May. 21 - June. 21: Tell that special someone exactly "
"exactly how you fell, sparks are bound to fly.
";
case 9:
cout << "Virgo Aug. 23 - Sep. 22: Summer is coming to an end, take your"
" favorite people out on one last trip.
";
case 11:
cout << "Scorpio Oct. 23 - Nov. 21: Play the lottery on Aug 29th chances"
" are good that you will become a millionaire.
";

if (day < 1 || day > 30)
{
cout<< "the day you entered is not valid for the month.
";
day = 0;
}
break;

case 2:
cout << "Aquarius Jan. 20 - Feb. 18: Now is the time to drink saki and to"
" celebrate this month.
";
if (day < 1 || day > 29)
{
cout<< "the day you entered is not valid for the month.
";
day = 0;
}
break;


}
} while (day == 0);

cout << "Enter birth month (invalid month will end the program):";
cin >> month;

}

system("pause");
return 0;

}

Sign In or Register to comment.