|
-
August 4th, 2012, 04:28 AM
#1
Need a little help :)
So recently i made this code for my homework:
Code:
#include <iostream>
using namespace std;
int main()
{
int date;
int month;
char ans;
cout<<"Enter your birth month and date to determine your zodiac sign\n\n"<<endl;
while (!((ans=='n') || (ans=='N')))
{
cout<<"Enter your birth month:";
cin>>month;
cout<<"Enter your birth date:";
cin>>date;
if (( month == 1 && date >= 20 && date <= 31 ) || ( month == 2 && date <=18 ))
{
cout<<"Your zodiac sign is AQUARIUS\n\n";
cout<<"Aquarius is an old constellation. As the Water Carrier or Water Bearer,\nhe is carved in stones";
cout<<"of the Babylonian Empire and probably is still older than that period.\n";
}
else if (( month == 2 && date >= 19 && date <= 28) || ( month == 3 && date <= 20))
{
cout<<"Your zodiac sign is PISCES\n\n";
cout<<"Pisces was named after Aphrodite and Eros.The story of Pisces originated from\n";
cout<<"the destructive monster, Typhon.\n";
}
else if (( month == 3 && date >= 21 && date <= 31) || ( month == 4 && date <= 19))
{
cout<<"Your zodiac sign is ARIES\n\n";
cout<<"Aries is a zodiacal constellation representing the ram of the Golden\n";
cout<<"Fleece sought by Jason and the Argonauts.\n";
}
else if (( month == 4 && date >= 20 && date <= 30 ) || ( month == 5 && date <= 20))
{
cout<<" Your zodiac sign is TAURUS\n";
}
else if (( month == 5 && date >= 21 && date <= 31 ) || ( month == 6 && date <= 20 ))
{
cout<<" Your zodiac sign is GEMINI\n";
}
else if (( month == 6 && date >= 21 && date <= 30 ) || ( month == 7 && date <= 22 ))
{
cout<<" Your zodiac sign is CANCER\n";
}
else if (( month == 7 && date <= 23 && date <= 31) || ( month == 8 && date <= 22))
{
cout<<" Your zodiac sign is LEO\n";
}
else if (( month == 8 && date >= 23 && date <= 31) || ( month == 9 && date <= 22 ))
{
cout<<" Your zodiac sign is VIRGO\n";
}
else if (( month == 9 && date >= 23 && date <= 30) || ( month == 10 && date <= 22))
{
cout<<" Your zodiac sign is LIBRA\n";
}
else if (( month == 10 && date >= 23 && date <= 31 ) || ( month == 11 && date <= 21))
{
cout<<" Your zodiac sign is SCORPIO\n";
}
else if (( month == 11 && date >= 22 && date <= 30 ) || ( month == 12 && date <= 21))
{
cout<<" Your zodiac sign is SAGUITTARIUS\n";
}
else if (( month == 12 && date >= 22 && date <= 31 ) || ( month == 1 && date <= 19 ))
{
cout<<" Your zodiac sign is CAPRICORN\n";
}
else
{
cout<<" INVALID INPUT\n";
}
cout<<"do you want to continue? y/n"<<endl;
cin>>ans;
}
if ( ans == 'n')
{
cout<<"Thank you for your precious time! :D\n\n";
}
system("pause");
}
but now i have another problem..the problem is i need to have a invalid input when the program asks "do you want to continue? Y/N"..for ex:
Do you want to continue? Y/N :
z (this is the input)
Sorry, i can only determine yes or no.
something like that..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|