forked from a-r-nida/HactoberFest2020-Beginers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Calender.cpp
110 lines (103 loc) · 1.86 KB
/
Calender.cpp
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include<iostream>
#include<cmath>
using namespace std;
int main ()
{
int year, start_day, type, n_days, month(1);
cout << "Enter the year you want the program to display. ";
cin >> year;
if ((year%400==0) || ((year%100==0) ^ (year%4==0)))
{
type = 1;
cout << "\nThe year is leap year.";
}
else
{
type = 0;
cout << "\nThe year is odd year.";
}
cout << "\nEnter the first day of January: 1 for Sunday, 2 for Monday, etc. ";
cin >> start_day;
while (start_day < 0 || start_day > 12)
{
cout << "\nThe number entered is invalid.\nPlease enter a number between 1 and 7. ";
cin >> start_day;
}
while (month <= 12)
{
switch (month)
{
case 1:
cout << "\n\nJanuary\n" << endl;
n_days = 31;
break;
case 2:
cout << "\n\nFebruary\n" << endl;
if (type = 1)
{
n_days = 29;
}
else
{
n_days = 28;
}
break;
case 3:
cout << "\n\nMarch\n" << endl;
n_days = 31;
break;
case 4:
cout << "\n\nApril\n" << endl;
n_days = 30;
break;
case 5:
cout << "\n\nMay\n" << endl;
n_days = 31;
break;
case 6:
cout << "\n\nJune\n" << endl;
n_days = 30;
break;
case 7:
cout << "\n\nJuly\n" << endl;
n_days = 31;
break;
case 8:
cout << "\n\nAugust\n" << endl;
n_days = 31;
break;
case 9:
cout << "\n\nSeptember\n" << endl;
n_days = 30;
break;
case 10:
cout << "\n\nOctober" << endl;
n_days = 31;
break;
case 11:
cout << "\n\nNovember" << endl;
n_days = 30;
break;
case 12:
cout << "\n\nDecember\n" << endl;
n_days = 31;
break;
default:
;
}
cout << endl << "Sun\tMon\tTue\tWed\tThr\tFri\tSat\n";
for (int i = 1; i < start_day; i++)
{
cout << " \t";
}
for (int j = 1; j <= n_days; j++)
{
if (((j + start_day - 2) % 7 == 0) && (j != 1))
cout << endl;
cout << j << "\t";
}
cout << endl << endl;
month ++;
}
return 0;
}