- #1
frixis
- 19
- 0
okay so they asked us to make an entire calendar where the user inputs the first day of the month and month itself and a calendar is generated for an entire year..
so far I've gotten to being able to generate a good thingi for a month.. and well I've used a while loop to repeat till the months get to 12... as in no matter wat month number u enter it'll get to december.. but like if u entered 4 it wudnt do months 4,5,6,7,8,9,10,11,12,1,2,3,4.. it'd do 4 to 12 only
and i also don't get how the next month to start from where the previous month ended..
i don't need the program thingi itself. but hints'd be nice..
heres my code so far:
#include<iostream.h>
int space;
int day;
int date;
int month;
int main ()
{
space=0;
cout<<"\t\t\t::CALENDAR::\n";
cout<<"\n\nenter number of month:\t";
cin>>month;
cout<<"\n\nenter first day of the month:\t";
cout<<"\n\nMonday = 0\nTuesady = 1\nWednesday = 2";
cout<<"\nThursday = 3\nFriday = 4\nSaturday = 5";
cout<<"\nSunday = 6\n";
cin>>day;
cout<<"\n\n\t\t";
while (month<=12)
{ if (month==1)
cout<<"JANUARY";
else if (month==2)
cout<<"FEBRUARY";
else if (month==3)
cout<<"MARCH";
else if (month==4)
cout<<"APRIL";
else if (month==5)
cout<<"MAY";
else if (month==6)
cout<<"JUNE";
else if (month==7)
cout<<"JULY";
else if (month==8)
cout<<"AUGUST";
else if (month==9)
cout<<"SEPTEMBER";
else if (month==10)
cout<<"OCTOBER";
else if (month==11)
cout<<"NOVEMBER";
else if (month==12)
cout<<"DECEMBER";
else
{cout<<"invalid month, calendar will close";
return 0;
}
cout<<"\n\nMon\tTue\tWed\tThu\tFri\tSat\tSun\n";
while (space<day)
{cout<<"\t";
space++;
}
if (month==4||month==6||month==9||month==11)
{
for (date=1;date<31;date++)
{
++space;
cout<<date;
cout<<"\t";
if (space%7==0)
{cout<<"\n";
}
}
}
else if (month==2)
{
for (date=1;date<29;date++)
{
++space;
cout<<date;
cout<<"\t";
if (space%7==0)
{cout<<"\n";
}
}
}
else
{for (date=1;date<=31;date++)
{
++space;
cout<<date;
cout<<"\t";
if (space%7==0)
{cout<<"\n";
}
}
}
month++;
cout<<"\n\n";
}
cout<<"\n\n";
return 0;
}
so far I've gotten to being able to generate a good thingi for a month.. and well I've used a while loop to repeat till the months get to 12... as in no matter wat month number u enter it'll get to december.. but like if u entered 4 it wudnt do months 4,5,6,7,8,9,10,11,12,1,2,3,4.. it'd do 4 to 12 only
and i also don't get how the next month to start from where the previous month ended..
i don't need the program thingi itself. but hints'd be nice..
heres my code so far:
#include<iostream.h>
int space;
int day;
int date;
int month;
int main ()
{
space=0;
cout<<"\t\t\t::CALENDAR::\n";
cout<<"\n\nenter number of month:\t";
cin>>month;
cout<<"\n\nenter first day of the month:\t";
cout<<"\n\nMonday = 0\nTuesady = 1\nWednesday = 2";
cout<<"\nThursday = 3\nFriday = 4\nSaturday = 5";
cout<<"\nSunday = 6\n";
cin>>day;
cout<<"\n\n\t\t";
while (month<=12)
{ if (month==1)
cout<<"JANUARY";
else if (month==2)
cout<<"FEBRUARY";
else if (month==3)
cout<<"MARCH";
else if (month==4)
cout<<"APRIL";
else if (month==5)
cout<<"MAY";
else if (month==6)
cout<<"JUNE";
else if (month==7)
cout<<"JULY";
else if (month==8)
cout<<"AUGUST";
else if (month==9)
cout<<"SEPTEMBER";
else if (month==10)
cout<<"OCTOBER";
else if (month==11)
cout<<"NOVEMBER";
else if (month==12)
cout<<"DECEMBER";
else
{cout<<"invalid month, calendar will close";
return 0;
}
cout<<"\n\nMon\tTue\tWed\tThu\tFri\tSat\tSun\n";
while (space<day)
{cout<<"\t";
space++;
}
if (month==4||month==6||month==9||month==11)
{
for (date=1;date<31;date++)
{
++space;
cout<<date;
cout<<"\t";
if (space%7==0)
{cout<<"\n";
}
}
}
else if (month==2)
{
for (date=1;date<29;date++)
{
++space;
cout<<date;
cout<<"\t";
if (space%7==0)
{cout<<"\n";
}
}
}
else
{for (date=1;date<=31;date++)
{
++space;
cout<<date;
cout<<"\t";
if (space%7==0)
{cout<<"\n";
}
}
}
month++;
cout<<"\n\n";
}
cout<<"\n\n";
return 0;
}