Question

C++ Programming Help: Horoscope Signs and Elements

x.øi5="lblDescription">Write an astrology program. The user types ina birthday, and the program responds with the sign and horoscope forthat birthday. The month maybe entered as a number from 1 to 12. Thenenhance your program so that if the birthday is only one or two daysaway from an adjacent sign, the program announces that thebirthday ison a "cusp" and also outputs the horoscope for that nearest adjacentsign. This program will have a long multiway branch. Make up ahoroscope for each sign.Your program should include a loop that letsthe user repeat this calculation until the user says she or he is done.
The horoscope signs and dates are :
Aries March 21-April 19
Taurus April 20-May 20
Gemini May 21-June 21
Cancer June 22-July 22
Leo July 23-August 22
Virgo August 23-September 22
Libra September 23-October 22
Scorpio October 23-November 21
Sagittarius November 22-December 21
Capricorn December 22-January 19
Aquarius January 20-February 18
Pisces February 19-March 20
Horoscope Signs of the same Element are most compatible. There are 4 Elements in astrology, and 3 Signs in each: FIRE (Aries, Leo, Sagittarius) EARTH (Taurus, Virgo,Capricorn) AIR (Gemini, Libra, Aquarius) WATER (Cancer, Scorpio, Pisces)
According to some astrologers, you are most comfortable with your own sign and the other two signs in your Element. For example, Aries would be most comfortable withother Aries and the two other FIRE signs, Leo and Sagittarius.

For the first one:
My problem is that I don't know how to formulate a loop process to reiterate the program. My conditions are probably wrong somewhere, and I just simply don't know whatto do anymore to create that loop. So please help with the loop process there.

#include <iostream.h>
#include <conio.h>

int main()
{
int month;
int day;
char ans;

cout << "Wanna know your horoscope sign?n"
<< "Use this program to find out!nn";
cout << "Enter an integer for the month of your birthday: ";
cin >> month;
cout << "Enter the day of that month: ";
cin >> day;
cout << endl;

do
{
switch (month)
{
case 1:
if (day < 20)
cout << "Your sign is CAPRICORN!n";
else
cout << "Your sign is AQUARIUS!n";
break;
case 2:
if (day < 19)
cout << "Your sign is AQUARIUS!n";
else
cout << "Your sign is PISCES!n";
break;
case 3:
if (day < 21)
cout << "Your sign is PISCES!n";
else
cout << "Your sign is ARIES!n";
break;
case 4:
if (day < 20)
cout << "Your sign is ARIES!n";
else
cout << "Your sign is TAURUS!n";
break;
case 5:
if (day < 21)
cout << "Your sign is TAURUS!n";
else
cout << "Your sign is GEMINI!n";
break;
case 6:
if (day < 22)
cout << "Your sign is GEMINI!n";
else
cout << "Your sign is CANCER!n";
break;
case 7:
if (day < 23)
cout << "Your sign is CANCER!n";
else
cout << "Your sign is LEO!n";
break;
case 8:
if (day < 23)
cout << "Your sign is LEO!n";
else
cout << "Your sign is VIRGO!n";
break;
case 9:
if (day < 23)
cout << "Your sign is VIRGO!n";
&nbsõbpx.øi5bsp;else
cout << "Your sign is LIBRA!n";
break;
case 10:
if (day < 23)
cout << "Your sign is LIBRA!n";
else
cout << "Your sign is SCORPIO!n";
break;
case 11:
if (day < 22)
cout << "Your sign is SCORPIO!n";
else
cout << "Your sign is SAGITTARIUS!n";
break;
case 12:
if (day < 22)
cout << "Your sign is SAGITTARIUS!n";
else
cout << "Your sign is CAPRICORN!n";
break;
}
} while (ans == 'y' || ans == 'Y');

getch();
}

For the second problem:
My program doesn't even compile and execute. I have these two errors:
expected primary-expression before "else"and expected `;' before "else"
I don't know what to do. Please help!

#include <iostream.h>
#include <conio.h>

int main()
{
int month;
int day;
char ans;

cout << "Wanna know your horoscope sign?n"
<< "Use this program to find out!nn";
cout << "Enter an integer for the month of your birthday: ";
cin >> month;
cout << "Enter the day of that month: ";
cin >> day;
cout << endl;

do
{
switch (month)
{
case 1:
if (day < 20)
cout << "Your sign is CAPRICORN!n";
cout << "Your element is EARTH!n";
else
cout << "Your sign is AQUARIUS!n";
cout << "Your element is AIR!n";
break;
case 2:
if (day < 19)
cout << "Your sign is AQUARIUS!n";
cout << "Your element is AIR!n";
else
cout << "Your sign is PISCES!n";
cout << "Your element is WATER!n";
break;
case 3:
if (day < 21)
cout << "Your sign is PISCES!n";
cout << "Your element is WATER!n";
else
cout << "Your sign is ARIES!n";
cout << "Your element is FIRE!n";
break;
case 4:
if (day < 20)
cout << "Your sign is ARIES!n";
cout << "Your element is FIRE!n";
else
cout << "Your sign is TAURUS!n";
cout << "Your element is EARTH!n";
break;
case 5:
if (day < 21)
cout << "Your sign is TAURUS!n";
cout << "Your element is EARTH!n";
else
cout << "Your sign is GEMINI!n";
cout << "Your element is AIR!n";
break;
case 6:
if (day < 22)
cout << "Your sign is GEMINI!n";
cout << "Your element is AIR!n";
else
cout << "Your sign is CANCER!n";
cout << "Your element is WATER!n";
break;
case 7:
if (day < 23)
cout << "Your sign is CANCER!n";
cout << "Your element is WATER!n";
else
cout << "Your sign is LEO!n";
cout << "Your element is FIRE!n";
break;
case 8:
if (day < 23)
cout << "Your sign is LEO!n";
cout << "Your element is FIRE!n";
else
cout << "Your sign is VIRGO!n";
cout << "Your element is EARTH!n";
break;
case 9:
if (day < 23)
cout << "Your sign is VIRGO!n";
cout << "Your element is EARTH!n";
else
cout << "Your sign is LIBRA!n";
cout << "Your element is AIR!n";
break;
case 10:
if (day < 23)
cout << "Your sign is LIBRA!n";
cout << "Your element is AIR!n";
else
cout << "Your sign is SCORPIO!n";
cout << "Your element is WATER!n";
break;
case 11:
if (day < 22)
cout << "Your sign is SCORPIO!n";
cout << "Your element is WATER!n";
else
cout << "Your sign is SAGITTARIUS!n";
cout << "Your element is FIRE!n";
break;
case 12:
if (day < 22)
cout << "Your sign is SAGITTARIUS!n";
cout << "Your element is FIRE!n";
else
cout << "Your sign is CAPRICORN!n";
cout << "Your element is EARTH!n";
&nbsùbp˜mx.bsp;break;
}
} while (ans == 'y' || ans == 'Y');

getch(

Solutions

Expert Solution
No answers


Submit Your Answer