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
|
#include<iostream>
#include<iomanip>
#include<cstring>
#include<string>
using namespace std;
// Static member variable type string to translate from integer to month-day format
// Class declaration
class DayOfYear
{
public:
int day;
int day2;
int day3;
string Month;
// Constructor function
DayOfYear(int dayEntered)
{
day = dayEntered;
} // end constructor function
void print()
{
if (day,day2,day3 >= 1 && day,day2,day3 <= 31)
{
cout << "January " << day << endl;
}
if (day, day2, day3 >= 32 && day, day2, day3 <= 59)
{
cout << "February " << (day, day2, day3 - 31) << endl;
}
if (day, day2, day3 >= 60 && day, day2, day3 <= 90)
{
cout << "March " << (day, day2, day3 - 59) << endl;
}
if (day, day2, day3 >= 91 && day, day2, day3 <= 120)
{
cout << "April " << (day, day2, day3 - 90) << endl;
}
if (day, day2, day3 >= 121 && day, day2, day3 <= 151)
{
cout << "May " << (day, day2, day3 - 120) << endl;
}
if (day, day2, day3 >= 152 && day, day2, day3 <= 181)
{
cout << "June " << (day, day2, day3 - 151) << endl;
}
if (day, day2, day3 >= 182 && day, day2, day3 <= 212)
{
cout << "July " << (day, day2, day3 - 181) << endl;
}
if (day, day2, day3 >= 213 && day, day2, day3 <= 243)
{
cout << "August " << (day - 212) << endl;
}
if (day, day2, day3 >= 244 && day, day2, day3 <= 273)
{
cout << "September " << (day, day2, day3 - 243) << endl;
}
if (day, day2, day3 >= 274 && day, day2, day3 <= 304)
{
cout << "October " << (day, day2, day3 - 273) << endl;
}
if (day, day2, day3 >= 305 && day, day2, day3 <= 334)
{
cout << "November " << (day, day2, day3 - 304) << endl;
}
if (day, day2, day3 >= 335 && day, day2, day3 <= 365)
{
cout << "December " << (day, day2, day3 - 334) << endl;
}
} // end print function
}; // end Class DayOfYear
int main()
{
// choose a day to print
DayOfYear day(78), day2(98);
// print day 78 in Month and Day format
cout << day(78) << day2(98);
system("Pause");
return 0;
}
|