Switch/case need help

So we have a weekend assignment that is "Write a c++ program that will allow a user to input their first name into a string, and use the switch/case statement to produce the following output. Your Program should prompt the use rwith the numbers and the options for each (school, classification, and mood) allowing them to make a choice"

My issue is with the output. The output at the end is the number that they input and not the name of the case they chose, so if they chose option 1 for school it does not print out "BRCC" at the end for the output it prints a 1. Any help would be great!

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
#include <iostream>
#include <string>
using namespace std;
int main(void)
{
	string name;
	cout << "Please enter your name: ";
	cin >> name;

	int school;
	cout << "Enter the school you attend" << endl;
	cout << "1. BRCC" << endl;
	cout << "2. LSU" << endl;
	cout << "3. SEU" << endl;
	cout << "4. SU" << endl;
	cin >> school;

	switch (school)
	{
	case 1:
		cout << "BRCC";
		break;
	case 2:
		cout << "LSU";
		break;
	case 3:
		cout << "SEU";
		break;
	case 4:
		cout << "SU";
		break;
	default:
		cout << "Invalid";
		break;

		cout << school;
	}

	int classyear;
	cout << endl << endl;
	cout << "What year are you at school?" << endl;
	cout << "1. Freshman" << endl;
	cout << "2. Sophomore" << endl;
	cout << "3. Junior" << endl;
	cout << "4. Senior" << endl;
	cin >> classyear;

	switch (classyear)
	{
	case 1:
		cout << "Freshman";
		break;
	case 2:
		cout << "Sophomore";
		break;
	case 3:
		cout << "Junior";
		break;
	case 4:
		cout << "Senior";
		break;
	default:
		cout << "Invalid";
		break;
	}

	int mood;
	cout << endl << endl;
	cout << "How are you feeling today?" << endl;
	cout << "1. Great" << endl;
	cout << "2. Good" << endl;
	cout << "3. Bad" << endl;
	cin >> mood;

	switch (mood)
	{
	case 1:
		cout << "Great";
		break;
	case 2:
		cout << "Good";
		break;
	case 3:
		cout << "Bad";
		break;
	default:
		cout << "Invalid";
		break;

	}

	cout << endl << endl;
	cout << "My name is " << name << endl;
	cout << "I am a student at " << school << endl;
	cout << "I am currently a " << classyear << endl;
	cout << "I am in a " << mood << " mood" << endl;

	return 0;
}
Last edited on
Please edit your post and make sure your code is [code]between code tags[/code] so that it has line numbers and syntax highlighting.

Which output is incorrect? I am having trouble understanding which you are referring to.
The issue it at the bottom where it says "I am a student at " << school << endl; it will give me the output as the number in which i input so if i input 1 for BRCC at the bottom it will output "1" instead of BRCC. im not sure how to get it to output the BRCC. It's the same problem with the other 3 cases.
I think you want each of your switch statements to come after you output each "I am ..." line.
yes. the way it is now it says "I am a student at 1(or whatever number they pick" and i want it to say "I am a student at BRCC(or whatever school corresponds to the number they picked)"
Ok, so that's just simple cut and paste - moving lines around. You already have all the code written out, just not in the right order ;)
Last edited on
I've been trying to move lines around but i still dont know which ones are not in the right order, but i still have no idea.
Never mind i FINALLY got it. thank you so much for your help (:
Topic archived. No new replies allowed.