I am have to create a program for my class. The instructions are to allow a user to input an integer and display the month and day that corresponds to the entered number. For example, user enters 32 and it will display February 1. I must create a DayOfYear class and create a function called print() to display the output message. I am a little lost and need some help. I compile my program and I get the following error message:
dayofyear.cpp(54) : error C2660: 'DayOfYear::print' : function does not take 1 arguments
#include <iostream>
#include <string>
using namespace std;
//Day of the year class declaration
class DayOfYear
{
private:
int day;
public:
static const int MonthDays[];
static const string MonthName[];
void print();
};
//**************************************************
// This function displays the month and day using *
// the number entered. *
//**************************************************
void DayOfYear::print()
{
int month = 0;
while (DayOfYear::MonthDays[month] < day)
month = (month + 1) %12;
//Display month and day
cout << DayOfYear::MonthName[month] << " " << day - DayOfYear::MonthDays[month-1];
};
int main()
{
//Set days of each month into an array
const int MonthDays[] = {31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365};
//Set the name of each month into an array
const string MonthName[] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
int day;
//Ask user the total day number
cout << "\nEnter a number you would like to convert into a month and day";
cin >> day;
//Error check for negative numbers and numbers higher than one year
if(day <= 0 || day > 365)
{
cout << "You must enter a valid number (1 thru 365)" << endl;
}
//Send entered day number to the print() function
DayOfYear::print(day);
return 0;
}