Can anyone help me tweek my code. This program is supposed to get the day number 1 through 365 from the user and display the corresponding month and day. I'm getting so many errors I don't know how to start or really decipher the error in C++. Here is my code. Any pointers would be greatly appreciated.
Here is the class.
//This is the Class for my Day Converter program
#ifndef DayConverter_H
#define DayConverter_H
#include <iostream>
#include <string>
Class DayConverter
{
private:
int day;
public:
static const int EndOfMonth[];
static const string Month[];
void print();
void setday(int d)
{day = d}
};
void DayConverter::print()
{
int month = 0;
//Do the math for gettig month info
While(EndOfMonth(month)< day);
month = (month+1) % 12;
//Display the month and day
if(month == 0)
cout<< "January" << day;
else
{
cout<< DayConverter::Month(month)<<" "
<<day - DayConverter::EndOfMonth[month-1];
}
};
#endif
And here is the .cpp file
// This is my Day Convert Program.
//It is supposed to convert the day of the year
// to the corresponding month and day.
#include <iostream>
#include <string>
#include "DayConverter.h"
using namespace std;
const string DayConverter::Month[] = {"Janurary", "February","March",
"April","May","June","July","August","Setpember","October","November","December"};
const int DayConverter::EndOfMonth[] = {31,59,90,120,151,181,212,243,273,304,
334,365};
int main()
{
DayConverter TI;
int day;
//Explain what this program will do
cout<< " This progam will take the day of the year from you."<<endl;
cout<< " and display the corresponding month and day."<<endl;
//Get the day number from the user
cout<< " Please enter the number of the day you would like to see: ";
cin>> day;
if(day <= 0 || day > 365)
{
cout<< " The number you enter isn't between 1 and 365." <<endl;
exit(1);
}
TI.setDay(day);
TI.print();
cout<< endl;
return 0;
}