Assuming that a year has 365 days, write a class named DayOfYear that takes an integer representing a day of the year and translates it to a string consisting of the month followed by day of the month. For example,
Day 2 would be January 2
Day 32 would be Febuary 1
Day 365 would be December 31
The constructor for the class should take as parameter an integer representing the day of the year, and the class should have a member function print() that prints the day in the month-day format. The class shuld have an integer member variable to represent the day, and shuld have static member variables of type string to assist in the translation from the integer format to the month-day format.
and this is waht i have got to set it up, but cannot think of how to complete it. Please help =(
#include <iostream>
#include <string>
using namespace std;
class DayOfYear
{
public:
DayOfYear(int d);
void print();
static string month[12];
private:
int day;
};
string DayOfYear::month[12] = {"January", "Febuary", "March", "Apirl", "May", "June",
"July", "August", "September", "October", "November", "December"};
DayOfYear::DayOfYear(int d)
{
day = d;
}
void DayOfYear::print()
{
cout << day;
}
int main()
{
DayOfYear test(12);
test.print();
cin.ignore();
cin.get();
return 0;
}