Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have seven error messages, five of them are the same, \"was not declared in th

ID: 3529796 • Letter: I

Question

I have seven error messages, five of them are the same, "was not declared in this scope," and the other two are, " cannot convert 'courseType to std:: string*" Often times, when I'm looking at a program for too long, I completely miss the obvious, I'm fairly certain this is one of thos times, at any rate, please don't judge me, lol. Thank you in advance. #include "enrollment.h" #include #include using namespace std; struct courseType{ //a struct named Course with three data members string courseNames; //a string containing the course name int maxEnrollments; //int containing the max enrollment int enrollments; //int containing the current enrollment }; /* * Read the course names and max enrollments. Keep the courses * in alphabetic order by course name. */ void readCourses (istream& courseFile, int numCourses, courseType list[]) { for (int i = 0; i < numCourses; ++i) { string name; int maxEnroll; courseFile >> name >> maxEnroll; int n = i; int whereInserted = addInOrder (list.courseNames, n, name); n = i; addElement (maxEnrollments, n, whereInserted, maxEnroll); } } /* * Read the enrollment requests, processing each one and tracking * the number of students successfully enrolled into each course. */ void processEnrollmentRequests (istream& enrollmentRequestsFile, int numCourses, string* courseNames, int* maxEnrollments, int* enrollments) { // Start the enrollment counters at zero for (int i = 0; i < numCourses; ++i) enrollments[i] = 0; // Read the requests, one at a time, serving each one string courseName; enrollmentRequestsFile >> courseName; while (enrollmentRequestsFile) { enrollmentRequestsFile >> ws; string studentName; getline (enrollmentRequestsFile, studentName); int pos = seqOrderedSearch (courseNames, numCourses, courseName); if (pos >= 0 && enrollments[pos] < maxEnrollments[pos]) { cout << studentName << " has enrolled in " << courseName << endl; ++enrollments[pos]; } else cout << studentName << " cannot enroll in " << courseName << endl; enrollmentRequestsFile >> courseName; } } /* * Write a CSV report listing each course and its enrollment. */ void generateReport (ostream& reportFile, int numCourses, string* courseNames, int* enrollments) { for (int i = 0; i < numCourses; ++i) { reportFile << '"' << courseNames[i] << '"' << "," << enrollments[i] << endl; } } int addInOrder (courseType list[], int& size, string value) { // Make room for the insertion int toBeMoved = size - 1; while (toBeMoved >= 0 && value < list[toBeMoved].courseNames) { list[toBeMoved+1]= list[toBeMoved]; --toBeMoved; } // Insert the new value list[toBeMoved+1].courseNames = value; ++size; return toBeMoved+1; } void processEnrollments (istream& courseFile, istream& enrollmentRequestsFile, ostream& reportFile) { int numCourses; courseFile >> numCourses; courseType course[numCourses]; readCourses (courseFile, numCourses, course); processEnrollmentRequests (enrollmentRequestsFile, numCourses, course); generateReport (reportFile, numCourses, course); }

Explanation / Answer

In processEnrollmentRequests you missed the opening bracket in your for loop. Could be causing the problems. I'll keep looking.