Untitled Document 1
Untitled Document 1
#include <string>
using namespace std;
class Student;
class Course;
// Department Class
class Department {
public:
int deptID;
string deptName;
void display() {
cout << "Dept ID: " << deptID << ", Name: " << deptName << endl;
}
};
// Course Class
class Course {
public:
int courseID;
string courseName;
Teacher* teacher;
Department* dept;
Student* students[10];
int studentCount;
Course() {
studentCount = 0;
teacher = NULL;
dept = NULL;
}
void display() {
cout << "Course ID: " << courseID << ", Name: " << courseName << endl;
if (dept != NULL)
cout << "Department: " << dept->deptName << endl;
if (teacher != NULL)
cout << "Assigned Teacher: " << teacher->name << endl;
}
// Student Class
class Student {
public:
int studentID;
string name;
Department* dept;
Course* courses[10];
float grades[10];
int courseCount;
Student() {
courseCount = 0;
dept = NULL;
}
void display() {
cout << "Student ID: " << studentID << ", Name: " << name << endl;
if (dept != NULL)
cout << "Enrolled in Department: " << dept->deptName << endl;
for (int i = 0; i < courseCount; i++) {
cout << "Enrolled in Course: " << courses[i]->courseName << endl;
}
}
void viewGrades() {
cout << "Grades for student " << name << ":\n";
for (int i = 0; i < courseCount; i++) {
cout << "Course: " << courses[i]->courseName << ", Grade: " << grades[i] << endl;
}
}
// Teacher Class
class Teacher {
public:
int teacherID;
string name;
Department* dept;
Course* course;
Teacher() {
dept = NULL;
course = NULL;
}
void display() {
cout << "Teacher ID: " << teacherID << ", Name: " << name << endl;
if (dept != NULL)
cout << "Assigned Department: " << dept->deptName << endl;
if (course != NULL)
cout << "Assigned Course: " << course->courseName << endl;
}
void viewStudentsInCourse() {
if (course == NULL) {
cout << "No course assigned.\n";
return;
}
cout << "Students enrolled in " << course->courseName << ":\n";
for (int i = 0; i < course->studentCount; i++) {
cout << course->students[i]->name << endl;
}
}
};
// Enrollment Class
class Enrollment {
public:
Student* student;
Course* course;
void input() {
cout << "Enter Student ID: ";
int studentID;
cin >> studentID;
cout << "Enter Course ID: ";
int courseID;
cin >> courseID;
}
void display() {
cout << "Student enrolled in course.\n";
}
};
// Result Class
class Result {
public:
float calculateResult(Student& student) {
float totalMarks = 0;
for (int i = 0; i < student.courseCount; i++) {
totalMarks += student.grades[i];
}
if (student.courseCount == 0)
return 0;
return totalMarks / student.courseCount;
}
};
// Librarian Class
class Librarian {
public:
int bookID;
string bookTitle;
bool isAvailable;
void addBook() {
cout << "Enter Book ID: ";
cin >> bookID;
cout << "Enter Book Title: ";
cin.ignore();
getline(cin, bookTitle);
isAvailable = true;
}
void display() {
cout << "Book ID: " << bookID << ", Title: " << bookTitle << ", Available: " << (isAvailable ?
"Yes" : "No") << endl;
}
// University Class
class University {
public:
string universityName;
Department departments[10];
Teacher teachers[10];
Student students[10];
Course courses[10];
Enrollment enrollments[10];
Librarian library[10];
int deptCount, teacherCount, studentCount, courseCount, enrollmentCount, bookCount;
University() {
deptCount = teacherCount = studentCount = courseCount = enrollmentCount = bookCount
= 0;
}
void inputUniversity() {
cout << "Enter University Name: ";
cin.ignore();
getline(cin, universityName);
}
void displayDepartments() {
cout << "\nDepartments:\n";
for (int i = 0; i < deptCount; i++) {
departments[i].display();
}
}
void displayTeachers() {
cout << "\nTeachers:\n";
for (int i = 0; i < teacherCount; i++) {
teachers[i].display();
}
}
void displayStudents() {
cout << "\nStudents:\n";
for (int i = 0; i < studentCount; i++) {
students[i].display();
}
}
void displayCourses() {
cout << "\nCourses:\n";
for (int i = 0; i < courseCount; i++) {
courses[i].display();
}
}
void displayLibrary() {
cout << "\nLibrary Books:\n";
for (int i = 0; i < bookCount; i++) {
library[i].display();
}
}
};