Birthday Program

Hello,
I have an assignment in which i must create a program which prompts for user input of current and birth date, which will compare said dates and output if its your birthday or not. I've completed a large portion of it, but cannot figure out how to get the user input of month as an integer such a 2 into february. any help is much appreciated.
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
#include <iostream>
using namespace std;
class DayOfYear
{
public:
void input();
void output();
void set(int new_month, int new_day);
int get_month();
int get_day();
string 
private:
void check_date();
int month;
int day;
};
void DayOfYear::
{
	switch(month)
	{
	case 1:
		cout<<"January"<<day;
		break;
	case 2:
		cout<<<"February"<<day;
		break;
	case 3:
		cout<<"March"<<day;
		break;
	case 4:
		cout<<"April"<<day;
		break;
	case 5:
		cout<<"May"<<day<<","<<year;
		break;
	case 6:
		cout<<"June"<<day<<","<<year;
		break;
	case 7:
		cout<<"July"<<day<<","<<year;
		break;
	case 8:
		cout<<"August"<<day<<","<<year;
		break;
	case 9:
		cout<<"September"<<day<<","<<year;
		break;
	case 10:
		cout<<"October"<<day<<","<<year;
		break;
	case 11:
		cout<<"November"<<day<<","<<year;
		break;
	case 12:
		cout<<"December"<<day<<","<<year;
		break;
	}
int main()
{
DayOfYear today, birthday;
cout << "Enter today's date: \n";
today.input();
cout << "Today's date is ";
today.output();
cout << "Enter your birthday: \n";
birthday.input();
cout << "Your birthday is ";
birthday.output();
if( today.get_month() == birthday.get_month() && today.get_day() == birthday.get_day())
cout << "Happy Birthday! \n";
else
cout <<"Happy Unbirthday! \n";
return 0;
}
void DayOfYear::input()
{
cout << "Enter the month as a number : ";
cin >> month;
cout << "Enter the day of the month: ";
cin >> day;
check_date();
}
void DayOfYear::output( )
{ cout << "month = " << month << ", day = " << day << endl;
}
void DayOfYear::set(int new_month, int new_day)
{
month= new_month;
day = new_day;
check_date();
}
void DayOfYear::check_date()
{
if ((month< 1) || (month > 12) ||(day < 1) || (day> 31))
{
cout << "Illegal date. Please try again. \n";
main();
}
}
int DayOfYear::get_month()
{
return month;
}
int DayOfYear::get_day()
{
return day;
}
In the class, you have the month as type int. Instead, try having it as type string.
Then, whenever the user enters a number for the month, do some if statements to set the month for the class based off of the input - that sounds confusing (This means in the input function, allow them to enter an int for the month)

Case:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
DayofYear::input
{
    cin >> "month as a number"
    getMonth("month as a number")
}

getMonth(int "month as a number")
{
    if("month as a number" == 1) today.month = "January";
    .
    .
    .
    else today.month = "December"
}


Something like that
Topic archived. No new replies allowed.