-
Notifications
You must be signed in to change notification settings - Fork 0
/
cpp assignment1_3.cpp
137 lines (89 loc) · 1.46 KB
/
cpp assignment1_3.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#include <iostream>
using namespace std;
class date
{
public:
int day,month,year;
public:
date()
{
this->day=04;
this->month=03;
this->year=2020;
}
date(int day, int month, int year)
{
this-> day = day;
this->month = month;
this->year = year;
}
};
date d(03,03,2020);
date d1;
int menu_list()
{
int choice;
cout<<endl<<"1:Accept Date"<<endl<<"2:Print Date"<<endl<<"3:Is Leap year";
cout<<endl<<" enter your choice"<<endl;
cin>>choice;
return choice;
}
void InitDate()
{
d.day=03;
d.month=03;
d.year=2020;
cout<<endl<<"Date is initialised"<<endl<<endl;
}
int Accept_date()
{
cout<<endl<<"enter day"<<endl;
cin>>d.day;
if(d.day < 0 || d.day > 31)
{
cout<<endl<<"Invalid Day"<<endl;
return 0;
}
cout<<endl<<"enter month"<<endl;
cin>>d.month;
if(d.day < 0 || d.day > 31)
{
cout<<endl<<"Invalid Month"<<endl;
return 0;
}
cout<<endl<<"enter year"<<endl;
cin>>d.year;
}
void Print_date()
{
cout<<endl<<"date is= "<<d.day<<"/"<<d.month<<"/"<<d.year<<endl<<endl<<endl;
}
void Is_leap_year()
{
bool t=true;
bool f=false;
if(d.year % 4 == 0 || d.year%400==0)
cout<<endl<<"Leap year"<<"bool:"<<t<<endl<<endl<<endl;
else
cout<<endl<<"not leap year"<<"bool:"<<f<<endl<<endl<<endl;
}
int main()
{
date d(03,03,2020);
date d1;
int choice=0;
while( ( choice = menu_list( ) ) != 0 )
switch(choice)
{
case 1:
Accept_date();
break;
case 2:
Print_date();
break;
case 3:
Is_leap_year();
break;
}
return 0;
}