-
Calendar Rage
Code:
#include <iostream>
#include <conio.h>
using namespace std;
main()
{
int month,day,year;
cout <<endl;
cout <<"Enter The Month Of Your Birthday:"<<endl<<"1=Jan 2=Feb 3=Mar 4=Apr 5=May 6=Jun 7=Jul 8=Aug 9=Sep 10=Oct 11=Nov 12=Dec: ";
cin >>month;
cout <<endl;
cout <<"Enter The Day Of Your Birthday:"<<endl<<" 1 - 31: ";
cin >>day;
cout <<endl;
cout <<"Enter The Year Of Your Birthday:"<<endl<<"80's - 06's: ";
cin >>year;
if (month = 1)
{
cout <<"Because your birthday is "<<month<<"/"<<day<<"/"<<year<<" your zodiac sign is Aquarius";
}
if (month = 2)
{
cout <<"Because your birthday is "<<month<<"/"<<day<<"/"<<year<<" your zodiac sign is Pisces";
}
if (month = 3)
{
cout <<"Because your birthday is "<<month<<"/"<<day<<"/"<<year<<" your zodiac sign is Aries";
}
if (month = 4)
{
cout <<"Because your birthday is "<<month<<"/"<<day<<"/"<<year<<" your zodiac sign is Taurus";
}
if (month = 5)
{
cout <<"Because your birthday is "<<month<<"/"<<day<<"/"<<year<<" your zodiac sign is Gemini";
}
if (month = 6)
{
cout <<"Because your birthday is "<<month<<"/"<<day<<"/"<<year<<" your zodiac sign is Cancer";
}
if (month = 7)
{
cout <<"Because your birthday is "<<month<<"/"<<day<<"/"<<year<<" your zodiac sign is Leo";
}
if (month = 8)
{
cout <<"Because your birthday is "<<month<<"/"<<day<<"/"<<year<<" your zodiac sign is Virgo";
}
if (month = 9)
{
cout <<"Because your birthday is "<<month<<"/"<<day<<"/"<<year<<" your zodiac sign is Libra";
}
if (month = 10)
{
cout <<"Because your birthday is "<<month<<"/"<<day<<"/"<<year<<" your zodiac sign is Scorpio";
}
if (month = 11)
{
cout <<"Because your birthday is "<<month<<"/"<<day<<"/"<<year<<" your zodiac sign is Sagitarius";
}
if (month = 12)
{
cout <<"Because your birthday is "<<month<<"/"<<day<<"/"<<year<<" your zodiac sign is Capricorn";
}
getch();
}
I have a problem with this i cant make a range of the birthdates ... like january 1 upto february 19 is aquarius ..... Feb. 20 - Mar. 20 is pisces and so on ....... i also try switch case but ... case is only read integer ....
-
Think hard about what the above code does.
-
Yeah, I get angry at the calendar sometimes as well.
In the meantime, you might want to replace all those = in your if statements with ==
If you're a mingw / dev-c++ user, then add "-W -Wall" to the compiler command line options.
Then remove that conio.h and swing by the FAQ to find other ways of keeping the console window on screen at the end of the program.
-
But how can i make some range on it ... like january 1 upto february 19 is aquarius ..... Feb. 20 - Mar. 20 is pisces ....
-
Like
if ( month == 1 && day <= 21 )
-
should really be
Also, try to indent your code, it makes for much easier reading and debugging
-
sry just a question I get confused sometimes on when to use cout<<endl can someone explain and use an example? this topic sheds some light though
-
cout << endl (or std::cout << std::endl) outputs a newline to the output buffer. endl expands to endline. And don't hijack other people's threads with your questions. Start your own.
-
It also flushes the buffer, which is often unnecessary but rarely harmful. You can use cout << '\n' instead.
-
In other words, cout << endl is the same as cout << '\n' << flush.
If you know how to use arrays (or even functions), you could simplify that code a lot.