- #1
sheepcountme
- 80
- 1
I'm dead awful at computer science, but I have to take the class, and I'm struggling.
I wrote the following code for an astrology program (I'm sure it's completely awkward, but please bear with me, it at least made it through a successful build).
The problem is, it asks for the month and day, but then just ends and doesn't output anything. Any help you could give me to fix this would be very much appreciated. The book hasn't been much help at all.
Here's the code...
#include <iostream>
using namespace std;
int main()
{
int month, day;
cout << "Enter the month you were born, from 1 to 12. ";
cin >> month;
cout << "Enter the day you were born from 1 to 31. ";
cin >> day;
if ( (month==10&&day>25) || (month==11&&day<19) ) {
cout << "You are a Scorpio! Today you should eat lots of cookies! ";
} else if ( (month==11&&day>=19&&day<=24) ) {
cout << "You were born on the cusp of Scorpio and Sagittarius! ";
cout << "Today you should eat lots of cookies and pet a kitten! ";
} else if ( (month==11&&day>24) || (month==12&&day<19) ) {
cout << "You are a Sagittarius! Today you should pet a kitten! ";
} else if ( (month==12&&day>=19&&day<=24) ) {
cout << "You were born on the cusp of Sagittarius and Capricorn! ";
cout << "Today you should pet a kitten and beware of snails! ";
} else if ( (month==12&&day>24) || (month==1&&day<17) ) {
cout << "You are a Capricorn! Beware of snails today! ";
} else if ( (month==1&&day>=17&&day<=22) ) {
cout << "You were born on the cusp of Capricorn and Aquarius! ";
cout << "Beware of snails today and bring an umbrella! ";
} else if ( (month==1&&day>22) || (month==2&&day<16) ) {
cout << "You are an Aquarius! Bring an umbrella today! ";
} else if ( (month==2&&day>=16&&day<=21) ) {
cout << "You were born on the cusp of Aquarius and Pisces! ";
cout << "Bring an umbrella today and wear something pink! ";
} else if ( (month==2&&day>21) || (month==3&&day<18) ) {
cout << "You are a Pisces! Wear something pink today! ";
} else if ( (month==3&&day>=18&&day<=23) ) {
cout << "You were born on the cusp of Pisces and Aries! ";
cout << "Wear something pink today and beware of cheese! ";
} else if ( (month==3&&day>23) || (month==4&&day<17) ) {
cout << "You are an Aries! Beware of cheese today! ";
} else if ( (month==4&&day>=17&&day<=22) ) {
cout << "You were born on the cusp of Aries and Taurus! ";
cout << "Beware of cheese today and wear your pants backwards! ";
} else if ( (month==4&&day>22) || (month==5&&day<18) ) {
cout << "You are a Taurus! Wear your pants backwards today! ";
} else if ( (month==5&&day>=18&&day<=23) ) {
cout << "You were born on the cusp of Taurus and Gemini! ";
cout << "Wear your pants backwards today and speak in Italian! ";
} else if ( (month==5&&day>23) || (month==6&&day<19) ) {
cout << "You are a Gemini! Speak in Italian today! ";
} else if ( (month==6&&day>=19&&day<=24) ) {
cout << "You were born on the cusp of Gemini and Cancer! ";
cout << "Speak in Italian today and kiss a walrus! ";
} else if ( (month==6&&day>24) || (month==7&&day<20) ) {
cout << "You are a Cancer! Kiss a walrus today! ";
} else if ( (month==7&&day>=20&&day<=25) ) {
cout << "You were born on the cusp of Cancer and Leo! ";
cout << "You shold kiss a walrus today and wear a tuxedo! ";
} else if ( (month==7&&day>25) || (month==8&&day<20) ) {
cout << "You are a Leo! You should wear a tuxedo today! ";
} else if ( (month==8&&day>=20&&day<=25) ) {
cout << "You were born on the cusp of Leo and Virgo! ";
cout << "Today you should wear a tuxedo and call everyone 'Henry'! ";
} else if ( (month==8&&day>25) || (month==9&&day<20) ) {
cout << "You are a Virgo! Today you should call everyone 'Henry'! ";
} else if ( (month==9&&day>=20&&day<=25) ) {
cout << "You were born on the cusp of Virgo and Libra! ";
cout << "Today you should call everyone 'Henry' and do the moonwalk! ";
} else if ( (month==9&&day>25) || (month==10&&day<20) ) {
cout << "You are a Libra! Today you should do the moonwalk! ";
} else if ( (month==10&&day>=20&&day<=25) ) {
cout << "You were born on the cusp of Libra and Scorpio! ";
cout << "Today you should do the moonwalk and eat lots of cookies! ";
}
}
I wrote the following code for an astrology program (I'm sure it's completely awkward, but please bear with me, it at least made it through a successful build).
The problem is, it asks for the month and day, but then just ends and doesn't output anything. Any help you could give me to fix this would be very much appreciated. The book hasn't been much help at all.
Here's the code...
#include <iostream>
using namespace std;
int main()
{
int month, day;
cout << "Enter the month you were born, from 1 to 12. ";
cin >> month;
cout << "Enter the day you were born from 1 to 31. ";
cin >> day;
if ( (month==10&&day>25) || (month==11&&day<19) ) {
cout << "You are a Scorpio! Today you should eat lots of cookies! ";
} else if ( (month==11&&day>=19&&day<=24) ) {
cout << "You were born on the cusp of Scorpio and Sagittarius! ";
cout << "Today you should eat lots of cookies and pet a kitten! ";
} else if ( (month==11&&day>24) || (month==12&&day<19) ) {
cout << "You are a Sagittarius! Today you should pet a kitten! ";
} else if ( (month==12&&day>=19&&day<=24) ) {
cout << "You were born on the cusp of Sagittarius and Capricorn! ";
cout << "Today you should pet a kitten and beware of snails! ";
} else if ( (month==12&&day>24) || (month==1&&day<17) ) {
cout << "You are a Capricorn! Beware of snails today! ";
} else if ( (month==1&&day>=17&&day<=22) ) {
cout << "You were born on the cusp of Capricorn and Aquarius! ";
cout << "Beware of snails today and bring an umbrella! ";
} else if ( (month==1&&day>22) || (month==2&&day<16) ) {
cout << "You are an Aquarius! Bring an umbrella today! ";
} else if ( (month==2&&day>=16&&day<=21) ) {
cout << "You were born on the cusp of Aquarius and Pisces! ";
cout << "Bring an umbrella today and wear something pink! ";
} else if ( (month==2&&day>21) || (month==3&&day<18) ) {
cout << "You are a Pisces! Wear something pink today! ";
} else if ( (month==3&&day>=18&&day<=23) ) {
cout << "You were born on the cusp of Pisces and Aries! ";
cout << "Wear something pink today and beware of cheese! ";
} else if ( (month==3&&day>23) || (month==4&&day<17) ) {
cout << "You are an Aries! Beware of cheese today! ";
} else if ( (month==4&&day>=17&&day<=22) ) {
cout << "You were born on the cusp of Aries and Taurus! ";
cout << "Beware of cheese today and wear your pants backwards! ";
} else if ( (month==4&&day>22) || (month==5&&day<18) ) {
cout << "You are a Taurus! Wear your pants backwards today! ";
} else if ( (month==5&&day>=18&&day<=23) ) {
cout << "You were born on the cusp of Taurus and Gemini! ";
cout << "Wear your pants backwards today and speak in Italian! ";
} else if ( (month==5&&day>23) || (month==6&&day<19) ) {
cout << "You are a Gemini! Speak in Italian today! ";
} else if ( (month==6&&day>=19&&day<=24) ) {
cout << "You were born on the cusp of Gemini and Cancer! ";
cout << "Speak in Italian today and kiss a walrus! ";
} else if ( (month==6&&day>24) || (month==7&&day<20) ) {
cout << "You are a Cancer! Kiss a walrus today! ";
} else if ( (month==7&&day>=20&&day<=25) ) {
cout << "You were born on the cusp of Cancer and Leo! ";
cout << "You shold kiss a walrus today and wear a tuxedo! ";
} else if ( (month==7&&day>25) || (month==8&&day<20) ) {
cout << "You are a Leo! You should wear a tuxedo today! ";
} else if ( (month==8&&day>=20&&day<=25) ) {
cout << "You were born on the cusp of Leo and Virgo! ";
cout << "Today you should wear a tuxedo and call everyone 'Henry'! ";
} else if ( (month==8&&day>25) || (month==9&&day<20) ) {
cout << "You are a Virgo! Today you should call everyone 'Henry'! ";
} else if ( (month==9&&day>=20&&day<=25) ) {
cout << "You were born on the cusp of Virgo and Libra! ";
cout << "Today you should call everyone 'Henry' and do the moonwalk! ";
} else if ( (month==9&&day>25) || (month==10&&day<20) ) {
cout << "You are a Libra! Today you should do the moonwalk! ";
} else if ( (month==10&&day>=20&&day<=25) ) {
cout << "You were born on the cusp of Libra and Scorpio! ";
cout << "Today you should do the moonwalk and eat lots of cookies! ";
}
}