This should be simple...

When this runs, choosing any letter "m" or further acts like I had chosen "l" and I don't know why.

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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
void menu()
{
	char choice = 'z';
	while (choice == 'z')
	{
		cout << "MENU:\na.\tList all the courses\nb.\tList all the students\nc.\tAdd a new course to the course list\nd.\tRemove a course from the course list\ne.\tList information of a course\nf.\tRegister a new student to the student list\ng.\tRemove a student from the student list\nh.\tRegister a course for a student\ni.\tDrop a course for a student\nj.\tList information of a student\nk.\tList all of a student's courses\nl.\tList all students enrolled in a course\nm.\tQuit\n\n";
		cin >> choice;
		if (choice == 'a')
		{
			listCourses();
			choice = 'z';
		}
		else if (choice == 'b')
		{
			listStudents();
			choice = 'z';
		}
		else if (choice == 'c')
		{
			string id;
			CCourse add;
			cout << "Type the course ID, title and number of units.\n";
			cin >> id >> add.title >> add.units;
			add.setId(id);
			addCourse(add);
			choice = 'z';
		}
		else if (choice == 'd')
		{
			string id;
			cout << "Enter a course ID to remove a course.\n";
			cin >> id;
			if (checkCourse)
			{
				removeCourse(id);
			}
			choice = 'z';
		}
		else if (choice == 'e')
		{
			string id;
			int i = 0;
			cout << "Enter a course ID to see the information of a course.\n";
			cin >> id;
			while (i < 5 && Courses[i].getid() != id)
			{
				i++;
			}
			cout << Courses[i];
			choice = 'z';
		}
		else if (choice == 'f')
		{
			CStudent add;
			cout << "Enter student informaiton to add a student.\n";
			cin >> add;
			addStudent(add);
			choice = 'z';
		}
		else if (choice == 'g')
		{
			string id;
			cout << "Enter a student ID to delete a student.\n";
			cin >> id;
			if (checkStudent(id))
			{
				removeStudent(id);
			}
			choice = 'z';
		}
		else if (choice == 'h')
		{
			string Student, add;
			cout << "Enter the ID of a student to enroll in a course, and the ID of the course they are enrolling in.\n";
			cin >> Student >> add;
			if (checkStudent(Student))
			{
				if (checkCourse(add))
				{
					registerCourse(Student, add);
				}
			}
			choice = 'z';
		}
		else if (choice == 'i')
		{
			string Student, drop;
			cout << "Enter the ID of a student to drop from a course, and the ID of the course they are dropping.\n";
			cin >> Student >> drop;
			if (checkStudent(Student))
			{
				if (checkCourse(drop))
				{
					dropCourse(Student, drop);
				}
			}
			choice = 'z';
		}
		else if (choice == 'j')
		{
			string id;
			int i = 0;
			cout << "Enter a student ID to see the information of a student.\n";
			cin >> id;
			if (checkStudent(id))
			{
				while (i < 10 && Students[i].getId() != id)
				{
					i++;
				}
				cout << Students[i];
			}
			choice = 'z';
		}
		else if (choice == 'k')
		{
			string id;
			cout << "Enter a student ID to see all of their classes.\n";
			cin >> id;
			if (checkStudent(id))
			{
				listStudentCourses(id);
			}
			choice = 'z';
		}
		else if (choice = 'l')
		{
			string id;
			cout << "Enter a course ID to see all the students enrolled in that class.\n";
			cin >> id;
			if (checkStudent(id))
			{
				listStudentsInCourse(id);
			}
			choice = 'z';
		}
		else if (choice = 'm')
		{
			break;
		}
		else
			choice = 'z';
	}
}
Fixed it. Had = instead of ==.

Just some advice, a switch statement would be better suited for this rather than a lot of IF statements.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

switch (choice)
{
	case 'a':
		// do your stuff for a
	break;

	case 'b':
		// do your stuff for b
	break;

	case 'c':
		// do your stuff for c
	break;

		// .. and so on

};
Topic archived. No new replies allowed.