Loop Improperly Executing with Array

I'm trying to recreate a basic student database and having trouble with the second half. It works the same whether or not I incorporate the first half, so I just appended the second portion below.
I can run the code just fine, but when it asks for the user to input 1 or 0, at the end, and I input it either one, the code will output the course previously entered, skip about four lines, and wait for the "cin >> stop;".

The BIOLOGYCOURSES file follows this format:

CC100
HP101
EN101
EN102
EN200
EN201

and so on.

Student_Transcript_Data is like this:

1067878
CS150
B
FA2014
1067878
RL101
C
SP2014
1067878
PH223
B
FA2014

**********************************************************

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

#include <iostream>
#include <string>
#include <sstream>
#include <istream>
#include <fstream>
#include <iomanip>

using namespace std;
int stop;

int main()
{

	const int MAX_Students = 6;
	bool CanTake = false;
	int RegistrationFinish = 0;
	int CourseDecrement = 3;

	ifstream inFile;
	ofstream outFile;
	ofstream NextSemester;
	ifstream BiologyCourses;
	ifstream CoursesTaken;

	string ChosenCourses[7];
	string CourseToTake;
	string BiologyArray[50];
	string RegistrationFinishString;
	string course;
	string StudentIDString;
	string StudentID;
	string CourseInput;

	
	BiologyCourses.open("E:/College Work/Intermediate Programming/BIOLOGYCOURSES.txt");
	NextSemester.open("E:/College Work/Intermediate Programming/Next_Semester.txt");
	CoursesTaken.open("E:/College Work/Intermediate Programming/Student_Transcript_Data.txt");


	struct CompletedCourses
	{
		string StudentID;
		string CourseID;
		string Grade;
		string DateTaken;
	};

	int index = 0;

	CompletedCourses CompletedCoursesArray[35];

	while (BiologyCourses)
		{
				getline (BiologyCourses, course);
				BiologyArray[index] = course;
				index++;
		}
	index = 0;

	while (CoursesTaken)
		{
				getline (CoursesTaken, CompletedCoursesArray[index].StudentID);
				getline (CoursesTaken, CompletedCoursesArray[index].CourseID);
				getline (CoursesTaken, CompletedCoursesArray[index].Grade);
				getline (CoursesTaken, CompletedCoursesArray[index].DateTaken);
				index++;
		}	
	index = 0;

	
	while (RegistrationFinish != 1)
	{
		CanTake = false;
		cout << "Enter the course you want to take." << endl;
		getline(cin, CourseToTake);
		cout << "Please enter your student ID." << endl;
		getline (cin, StudentID);
		stringstream(StudentIDString) >> StudentID;
		

		
			if (BiologyArray[index] == CourseToTake)
			{
				cout << endl << "You may take " << CourseToTake << "." << endl;
				
			if ((StudentID == CompletedCoursesArray[index].StudentID) && (CourseToTake == CompletedCoursesArray[index].CourseID))
			{
				cout << "You have already taken this course and made a(n) " << CompletedCoursesArray[index].Grade << "." << endl;
			}
				ChosenCourses[CourseDecrement] = CourseToTake;
				CanTake = true;
				CourseDecrement--;
				index++;
			}
		index = 0;

	if (CanTake == false)
		{
			cout << endl << "You may not take this course(s)." << endl;
		}
		
	if (CourseDecrement > 0)
		{
			cout << endl << "You may register " << CourseDecrement << " more course(s)." << endl;
			cout << endl << "Enter 1 if you are finished. Enter 0 to continue to add courses." << endl;
			getline (cin, RegistrationFinishString);
			stringstream(RegistrationFinishString) >> RegistrationFinish;
		}

	if (CourseDecrement == 0)
		{
			cout << endl << "All course slots have been filled." << endl;
			RegistrationFinish = 1;
		}													
	
	for (int index = 3; index >= 0; index--)
		{
			cout << ChosenCourses[index] << endl;
		}
	}

	
		NextSemester.close();
		CoursesTaken.close();
		BiologyCourses.close();

	cin >> stop;
	return 0;
}
Topic archived. No new replies allowed.