Enum and Switch

I have this program made already and it works and everything, but instead of case '1' they want me to put case 'Mon'. how would I make it do that.



#include <iostream>
#include <cmath>

using namespace std;

int main(void)
{
char cDay;
char cA;

enum cDay{Mon = 1, Tue, Wed, Thur, Fri};
cout << " which day of the week, ....." << endl;
cin >> cA;

cDay = cA;
switch( cDay)
{
case '1':
cout << "Monday is work" << endl;
break;
case '2':
cout << "Tuesday is study" << endl;
break;
case '3':
cout << "Wednesday is play" << endl;
break;
case '4':
cout << "Thursday is TA run" << endl;
break;
case '5':
cout << "Friday is TA go out" << endl;
break;

};


return 1;
}

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
#include <iostream>
#include <cmath>

using namespace std;

int main(void)
{
	int cA; // <= should be int, not char

	char cDay; // <= why both the same name??

	enum cDay // <= why both the same name??
	{
		Mon = 1, Tue, Wed, Thur, Fri
	};
	cout << " which day of the week, ....." << endl;
	cin >> cA;

	cDay = cA; // why?? why not just switch on cA??
	switch(/*cDay*/ cA)
	{
		case Mon: // <= like this
			cout << "Monday is work" << endl;
			break;
		case '2':
			cout << "Tuesday is study" << endl;
			break;
		case '3':
			cout << "Wednesday is play" << endl;
			break;
		case '4':
			cout << "Thursday is TA run" << endl;
			break;
		case '5':
			cout << "Friday is TA go out" << endl;
			break;

	};

	return 1;
}
Last edited on
Ok, we i run the program and type in Mon nothing the " " from cout doesnt come out, thanks for taking time to view my program as well
Oh, i dont think that would be possible to ask to type Mon, since it has to be an interger but the program will work like this.



#include <iostream>
#include <cmath>

using namespace std;

int main(void)
{
int cA;



enum cDay
{
Mon = 1, Tue, Wed, Thur, Fri
};
cout << " which day of the week, ....." << endl;
cin >> cA;

switch( cA)
{
case Mon:
cout << "Monday is work" << endl;
break;
case Tue:
cout << "Tuesday is study" << endl;
break;
case Wed:
cout << "Wednesday is play" << endl;
break;
case Thur:
cout << "Thursday is TA run" << endl;
break;
case Fri:
cout << "Friday is TA go out" << endl;
break;

};

return 1;
}
Topic archived. No new replies allowed.