-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCPTR142_A1.cpp
More file actions
75 lines (63 loc) · 1.35 KB
/
CPTR142_A1.cpp
File metadata and controls
75 lines (63 loc) · 1.35 KB
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
#include <cstdlib>
#include <iostream>
using namespace std;
class Date //this is an abstract data type!!
{
private:
int month, day, year;
public:
Date(int,int,int);
Date(int=20070104);
void setDate(int, int, int);
void showDate(void);
int dayofwk(void); //makes it able to call the function
};
int Date::dayofwk()
{
int mm, dd, yyyy, A, B;
A=23*mm/9+dd+4;
if(mm<3)
B=yyyy--;
else
B=yyyy-2;
return (A+B+yyyy/4-yyyy/100+yyyy/400);
}
Date::Date(int mm, int dd, int yyyy)
{
cout<<"Object created"<<endl;
month=mm;
day=dd;
year=yyyy;
}
Date::Date(int yyyymmdd)
{
year = yyyymmdd/10000;
month = (yyyymmdd-(year*10000))/100;
day = yyyymmdd-year*10000-month*100;
}
void Date::setDate(int mm, int dd, int yyyy)
{
month=mm;
day=dd;
year=yyyy;
}
void Date::showDate(void)
{
cout << "The date is " << month << "/" << day << "/" << year << endl;
}
int main(int argc, char *argv[])
{
int mm, dd, yyyy;
Date a, b, c;
a.setDate(int, int, int);
cout<<"Month: ";
cin>>mm;
cout<<"Day: ";
cin>>dd;
cout<<"Year: ";
cin>>yyyy;
string n[]={"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
cout<<a.showDate()<< n[a.dayofwk()];
system("PAUSE");
return EXIT_SUCCESS;
}