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
|
#include <iostream>
#include <iomanip>
using namespace std;
int cal;
int getMonth()
{
int month;
cout << "Enter A Month Number: ";
cin >> month;
while (month < 1 or month > 12)
{
cout << "Must Be Between 1 and 12: " << endl;
cout << "Enter A Month Number: ";
cin >> month;
}
return month;
}
int getYear()
{
int year;
cout << "Enter A Year: ";
cin >> year;
while (year < 1940)
{
cout << "Year Must be 1940 or later: " << endl;
cout << "Enter A Year: ";
cin >> year;
}
return year;
}
void monthset(int month, int year)
{
if (month == 1)
cout << "January, " << year << endl;
if (month == 2)
cout << "February, " << year << endl;
if (month == 3)
cout << "March, " << year << endl;
if (month == 4)
cout << "April, " << year << endl;
if (month == 5)
cout << "May, " << year << endl;
if (month == 6)
cout << "June, " << year << endl;
if (month == 7)
cout << "July, " << year << endl;
if (month == 8)
cout << "August, " << year << endl;
if (month == 9)
cout << "September, " << year << endl;
if (month == 10)
cout << "October, " << year << endl;
if (month == 11)
cout << "November, " << year << endl;
if (month == 12)
cout << "December, " << year << endl;
}
int getDay()
{
int day;
cout << "Enter A Day: ";
cin >> day;
while (day < 1 or day > 31)
{
cout << "Please Enter A Day that is either 28, 30, 31" << endl;
cout << "Enter A Day: ";
cin >> day;
}
return day;
}
void display(int month, int days, int year)
{
cout << " Su Mo Tu We Th Fr Sa" << endl;
int pos = 1;
month = (month + 0) % 7;
for (int s = 0; s < month; s++, pos++)
{
cout << " ";
}
for (int j = 1; j <= days; j++, pos++)
{
if (pos % 8 == 0)
{
pos = 1;
cout << endl;
}
cout << setw(4) << j;
}
cout << endl;
}
int main()
{
// Get Month
int month = getMonth();
// Get Year
int year = getYear();
// Get Offset
monthset(month, year);
// Get days
int days = getDay();
// Get display
display(month, days, year);
cin >> cal;
return cal;
}
|