Question: Please help me debug this program! #include #include using namespace std; class Student { private: int id; string firstName; string lastName; int phone; string emailID;
Please help me debug this program!
#include
using namespace std;
class Student { private: int id; string firstName; string lastName; int phone; string emailID; float GPA; int classRank, exit; public: Student(int sID, string fname, string lname, int number, string email, float gpa, int rank) { id = sID; firstName = fname; lastName = lname; phone = number; emailID = email; GPA = gpa; classRank = rank; }
int getClassRank() { return classRank; }
void setClassRank(int classRank) { this->classRank = classRank; }
string getEmailId() { return emailID; }
void setEmailId( string emailId) { emailID = emailId; }
string getFirstName() { return firstName; }
void setFirstName( string firstName) { this->firstName = firstName; }
float getGpa() const { return GPA; }
void setGpa(float gpa) { GPA = gpa; }
int getId() const { return id; }
void setId(int id) { this->id = id; }
string getLastName() { return lastName; }
void setLastName( string lastName) { this->lastName = lastName; }
int getPhone() { return phone; }
void setPhone(int phone) { this->phone = phone; }
void printStudent() { cout<<"Student ID: "< class Schedule { private: int StudentID; int classNumber; int creditHours; public: Schedule(int id, int number, int hours) { StudentID = id; classNumber = number; creditHours = hours; } int getClassNumber() { return classNumber; } void setClassNumber(int classNumber) { this->classNumber = classNumber; } int getCreditHours() { return creditHours; } void setCreditHours(int creditHours) { this->creditHours = creditHours; } int getStudentId() { return StudentID; } void setStudentId(int studentId) { StudentID = studentId; } void printSchdule() { cout<<"Student ID: "< Student ** students = new Student*[20]; Schedule ** schedules = new Schedule*[20]; int numberOfStudents = 0; int numberOfSchedules = 0; void addStudent() { int id, number, rank; float gpa; string fname, lname, email; cout<<" Enter student ID: "; cin>>id; cout<<" Enter student first name: "; cin>>fname; cout<<" Enter student last name: "; cin>>lname; cout<<" Enter student phone number: "; cin>>number; cout<<" Enter student email ID: "; cin>>email; cout<<" Enter student GPA: "; cin>>gpa; cout<<" Enter student rank: "; cin>>rank; students[numberOfStudents] = new Student(id, fname, lname, number, email, gpa, rank); numberOfStudents++; } void deleteStudent() { int studentID; cout<<" Enter the student id to delete: "; cin>>studentID; for(int i=0; i } else { for(int j=i; j void printStudentInfo(int id) { bool isStudentAvailable = false; for(int i=0; i void printScheduleforStudentID() { int studentID; cout<<" Enter the student ID to get the schedule: "; cin>>studentID; bool isSchudulePrinted = false; for(int i=0; i void addStudentToSchedule() { int studentID, classNumber, creditHours; cout<<" Enter the Student id to add to the Schedule: "; cin>>studentID; cout<<" Enter the class number: "; cin>>classNumber; cout<<" Enter the credit hours for the student: "; cin>>creditHours; schedules[numberOfSchedules] = new Schedule(studentID, classNumber, creditHours); numberOfSchedules++; } int main() { students[0] = new Student(1001, "Erik", "Hnida", 98764321, "BigDaddyG@hmail.com", 2.6, 20); numberOfStudents++; char choice = 'Y'; while(choice == 'y' || choice == 'Y') { int option; cout<<" Choose an option. 1. Add a student 2. Add a student to schedule 3. Display a schedule for student 4. Display a student 5. Delete a student 6. Exit"; cout<<" Enter your choice: "; cin>>option; switch(option) { case 1: addStudent(); cout<<" Do you want to continue: Y or N? "; cin>>choice; break; case 2: addStudentToSchedule(); cout<<" Do you want to continue: Y or N? "; cin>>choice; break; case 3: printScheduleforStudentID(); cout<<" Do you want to continue: Y or N? "; cin>>choice; break; case 4: int id; cout<<" Enter student id: "; cin>>id; printStudentInfo(id); cout<<" Do you want to continue: Y or N? "; cin>>choice; break; case 5: deleteStudent(); cout<<" Do you want to continue: Y or N? "; cin>>choice; break; case 6: exit(0); } } return 0; } } 247: #include using namespace std; class Student { private: int id; string firstName; string lastName; int phone; string emailID; float GPA; int classRank, exit; public: Student(int sID, string fname, string lname, int number, string email, float gpa, int rank) { id = sID; firstName = fname; lastName = lname; phone = number; emailID = email; GPA = gpa; classRank = rank; } int getClassRank() { return classRank; } void setClassRank(int classRank) { this->classRank = classRank; } string getEmailId() { return emailID; } void setEmailId( string emailId) { emailID = emailId; } string getFirstName() { return firstName; } void setFirstName( string firstName) { this->firstName = firstName; } float getGpa() const { return GPA; } void setGpa(float gpa) { GPA = gpa; } int getId() const { return id; } void setId(int id) { this->id = id; } string getLastName() { return lastName; } void setLastName( string lastName) { this->lastName = lastName; } int getPhone() { return phone; } void setPhone(int phone) { this->phone = phone; } void printStudent() { cout<<"Student ID: "< class Schedule { private: int StudentID; int classNumber; int creditHours; public: Schedule(int id, int number, int hours) { StudentID = id; classNumber = number; creditHours = hours; } int getClassNumber() { return classNumber; } void setClassNumber(int classNumber) { this->classNumber = classNumber; } int getCreditHours() { return creditHours; } void setCreditHours(int creditHours) { this->creditHours = creditHours; } int getStudentId() { return StudentID; } void setStudentId(int studentId) { StudentID = studentId; } void printSchdule() { cout<<"Student ID: "< Student ** students = new Student*[20]; Schedule ** schedules = new Schedule*[20]; int numberOfStudents = 0; int numberOfSchedules = 0; void addStudent() { int id, number, rank; float gpa; string fname, lname, email; cout<<" Enter student ID: "; cin>>id; cout<<" Enter student first name: "; cin>>fname; cout<<" Enter student last name: "; cin>>lname; cout<<" Enter student phone number: "; cin>>number; cout<<" Enter student email ID: "; cin>>email; cout<<" Enter student GPA: "; cin>>gpa; cout<<" Enter student rank: "; cin>>rank; students[numberOfStudents] = new Student(id, fname, lname, number, email, gpa, rank); numberOfStudents++; } void deleteStudent() { int studentID; cout<<" Enter the student id to delete: "; cin>>studentID; for(int i=0; i } else { for(int j=i; j void printStudentInfo(int id) { bool isStudentAvailable = false; for(int i=0; i void printScheduleforStudentID() { int studentID; cout<<" Enter the student ID to get the schedule: "; cin>>studentID; bool isSchudulePrinted = false; for(int i=0; i void addStudentToSchedule() { int studentID, classNumber, creditHours; cout<<" Enter the Student id to add to the Schedule: "; cin>>studentID; cout<<" Enter the class number: "; cin>>classNumber; cout<<" Enter the credit hours for the student: "; cin>>creditHours; schedules[numberOfSchedules] = new Schedule(studentID, classNumber, creditHours); numberOfSchedules++; } int main() { students[0] = new Student(1001, "Erik", "Hnida", 98764321, "BigDaddyG@hmail.com", 2.6, 20); numberOfStudents++; char choice = 'Y'; while(choice == 'y' || choice == 'Y') { int option; cout<<" Choose an option. 1. Add a student 2. Add a student to schedule 3. Display a schedule for student 4. Display a student 5. Delete a student 6. Exit"; cout<<" Enter your choice: "; cin>>option; switch(option) { case 1: addStudent(); cout<<" Do you want to continue: Y or N? "; cin>>choice; break; case 2: addStudentToSchedule(); cout<<" Do you want to continue: Y or N? "; cin>>choice; break; case 3: printScheduleforStudentID(); cout<<" Do you want to continue: Y or N? "; cin>>choice; break; case 4: int id; cout<<" Enter student id: "; cin>>id; printStudentInfo(id); cout<<" Do you want to continue: Y or N? "; cin>>choice; break; case 5: deleteStudent(); cout<<" Do you want to continue: Y or N? "; cin>>choice; break; case 6: exit(0); } } return 0; } } 247, 260: A function definition is not allowed here before the "}" token 302: Expected "}" at end of input
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
