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 <iostream>
using namespace std;
void addNumbers(int m, int d, int y, int c)
{
cout << "The day of the week is: " << (d + m + y + (y/4) + c)%7 << endl;
}
int main()
{
//example: 3rd January 1350 is a sunday
int day;
int month;
int year;
int century;
//day of the month: 3
cout << "This program will tell you the day of the inputs:" << endl;
cout << "What is the day of the month?: "<< endl;
cin >> day;
//month: 0
cout << "What is the number of the month from the months table?: "<< endl;
cout << "Jan, Oct = 0"<< endl;
cout << "May = 1"<< endl;
cout << "Aug = 2"<< endl;
cout << "Feb, Mar, Nov = 3"<< endl;
cout << "Jun = 4"<< endl;
cout << "Sep, Dec = 5"<< endl;
cout << "Apr, Jul = 6"<< endl;
cout << "Exceptions: If it is a leap year, Feb = 2 and Jan = 6"<< endl;
cin >> month;
//last 2 digits: 50
cout << "What is the last 2 digits in the year?: "<< endl;
cin >> year;
//century: 6
cout << "What is the century's number in the 100s of years table?: "<< endl;
cout << "14th century: 6" << endl;
cout << "15th century: 5" << endl;
cout << "16th century: 4" << endl;
cout << "17th century: 3" << endl;
cout << "18th century: 2" << endl;
cout << "19th century: 1" << endl;
cout << "20th century: 0" << endl;
cin >> century;
addNumbers(day,month,year,century);
if(addNumbers(day,month,year,century)==0)
{
cout << "The day of the week is: saturday";
}
if(addNumbers(day,month,year,century)==1)
{
cout << "The day of the week is: sunday";
}
if(addNumbers(day,month,year,century)==2)
{
cout << "The day of the week is: monday";
}
if(addNumbers(day,month,year,century)==3)
{
cout << "The day of the week is: tuesday";
}
if(addNumbers(day,month,year,century)==4)
{
cout << "The day of the week is: wednesday";
}
if(addNumbers(day,month,year,century)==5)
{
cout << "The day of the week is: thursday";
}
if(addNumbers(day,month,year,century)==6)
{
cout << "The day of the week is: friday";
}
return 0;
}
|