Calender program
Dec 21, 2010 at 4:34pm UTC
Hi!! I want to write a calender program. Below is my code but the dates wont line up properly. any suggestions? also is it possible to make an infinite calender program this way? cheers
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main(){
int Year,Month,FirstDay,NumberOfDaysInMonth;
int FirstDayOfMonth = 0;
int DayOfWeekCounter = 0;
int DateCounter = 1;
int Date;
cout<<" Calender 2010" <<endl<<endl;
for (Month = 1; Month <= 12; Month++){
cout<<"_______________________________________" <<endl<<endl;
cout<<"Mon Tue Wed Thu Fri Sat Sun" <<endl<<endl;
for (int j=1; j<=31; j++){
Date=j;
cout<<Date;
}
switch (Month){
case 1:
cout<<"January " <<endl<<endl;
NumberOfDaysInMonth = 31;
break ;
case 2:
cout<<"February " <<endl<<endl;
if (Year%400 == 0 || (Year % 4==0 && Year%100!= 0))
NumberOfDaysInMonth = 29;
else
NumberOfDaysInMonth = 28;
break ;
case 3:
cout<<"March " <<endl<<endl;
NumberOfDaysInMonth = 31;
break ;
case 4:
cout<<"April " <<endl<<endl;
NumberOfDaysInMonth = 30;
break ;
case 5:
cout<<"May " <<endl<<endl;
NumberOfDaysInMonth = 31;
break ;
case 6:
cout<<"June " <<endl<<endl;
NumberOfDaysInMonth = 30;
break ;
case 7:
cout<<"July " <<endl<<endl;
NumberOfDaysInMonth = 31;
break ;
case 8:
cout<<"August " <<endl<<endl;
NumberOfDaysInMonth = 31;
break ;
case 9:
cout<<"September " <<endl<<endl;
NumberOfDaysInMonth = 30;
break ;
case 10:
cout<<"October " <<endl<<endl;
NumberOfDaysInMonth = 31;
break ;
case 11:
cout<<"November " <<endl<<endl;
NumberOfDaysInMonth = 30;
break ;
case 12:
cout<<"December " <<endl<<endl;
NumberOfDaysInMonth = 31;
break ;
}
}
system("PAUSE" );
return 0;
}
Jan 16, 2011 at 12:55pm UTC
Any Idea here?
Jan 16, 2011 at 1:07pm UTC
Topic archived. No new replies allowed.