0% found this document useful (0 votes)
6 views

UNIVERSITY MANG SYSTEM OOP PROJECT

Uploaded by

aliib2936
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

UNIVERSITY MANG SYSTEM OOP PROJECT

Uploaded by

aliib2936
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 6

#include<iostream>

#include<string>
#include<vector>
#include <map>
using namespace std;
class person{
protected:
int id;
string name;
public:
person(const string& n , int i): name(n),id(i) {}
virtual void display() const =0;
int getid() const {
return id;
}
string getname() const {
return name;
}
};
class student: public person {
private:
vector<string>courses;
double fees;
public:
student(const string name ,int id): person(name,id),fees(0.0){}
void enrolCourse(const string& course) {
courses.push_back(course);
}
void setfees(double fee){
fees=fee;
}
double getfees() const {
return fees;
}
void display() const override {
cout<<" STUDENT NAME :"<<name<< "STUDENT ID"<<id<< "\nCOURSES ENROLLED : \
n";
for(const auto& course : courses) {
cout<<"- "<<course<<endl;
}
cout<<"FEES : $"<<fees<<endl;
}
};
class teacher:public person {
private:
vector<string>courses;
public:
teacher(const string& name, int id) :person(name, id) {}

void assignCourse(const string& course) {


courses.push_back(course);
}

void display() const override {


cout << "TEACHER NAME: " << name << ", ID: " << id << "\nCourses Assigned:\
n";
for (const auto& course : courses)
{
cout << "- " << course << endl;
}
}
};
class FeeDetails{
private:
map<int, double> studentFees;
public:
void addFee(int studentId, double fee)
{
studentFees[studentId] = fee;
}

double getFee(int studentId) const


{
if (studentFees.find(studentId) != studentFees.end())
{
return studentFees.at(studentId);
}
return 0.0;
}
void display() const {
cout << "Fee Details:\n";
for (const auto& entry : studentFees) {
cout << "Student ID: " << entry.first << ", Fee: $" << entry.second <<
endl;
}
}
};
class Transcript{
private:
map<int, map<string, string>> studentGrades;
public:
void addGrade(int studentId, const string& course, const string& grade) {
studentGrades[studentId][course] = grade;
}

void display(int studentId) const {


cout << "Transcript for Student ID: " << studentId << "\n";
if (studentGrades.find(studentId) != studentGrades.end()) {
for (const auto& entry : studentGrades.at(studentId)) {
cout << "Course: " << entry.first << ", Grade: " << entry.second <<
endl;
}
} else {
cout << "No grades available." << endl;
}
}
};
class University{
private:
vector<student>students;
vector<teacher>teachers;
FeeDetails feeDetails;
Transcript transcript;

public:
void addStudent(const student& student)
{
students.push_back(student);
}

void addTeacher(const teacher& teacher)


{
teachers.push_back(teacher);
}

void addFee(int studentId, double fee)


{
feeDetails.addFee(studentId, fee);
student* student = findStudentById(studentId);
if (student){
student->setfees(fee);
}
}

void addGrade(int studentId, const string& course, const string& grade){


transcript.addGrade(studentId, course, grade);
}
student* findStudentById(int id){
for (auto& student : students){
if (student.getid() == id){
return &student;
}
}
return nullptr;
}
teacher* findTeacherById(int id){
for (auto& teacher : teachers){
if (teacher.getid() == id){
return &teacher;
}
}
return nullptr;
}
void displayAllStudents() const{
for (const auto& student : students){
student.display();
cout << endl;
}
}
void displayAllTeachers() const{
for (const auto& teacher : teachers){
teacher.display();
cout << endl;
}
}
void displayAllFees() const{
feeDetails.display();
}
void displayTranscript(int studentId) const{
transcript.display(studentId);
}
};
void displayWelcomeNote()
{
cout << "=====================================" << endl;
cout << " Welcome to the University Management System " << endl;
cout << "=====================================" << endl << endl;
}
void displayMenu(){
cout << "Main Menu:" << endl;
cout << "1. Add Student" << endl;
cout << "2. Add Teacher" << endl;
cout << "3. Enroll Student in Course" << endl;
cout << "4. Assign Course to Teacher" << endl;
cout << "5. Add Fee for Student" << endl;
cout << "6. Add Grade for Student" << endl;
cout << "7. Display All Students" << endl;
cout << "8. Display All Teachers" << endl;
cout << "9. Display All Fees" << endl;
cout << "10. Display Transcript for Student" << endl;
cout << "11. Exit" << endl;
cout << "Enter your choice: ";
}
void addStudent(University& uni)
{
string name;
int id;
cout << "Enter student name: ";
cin.ignore();
getline(cin, name);
cout << "Enter student ID: ";
cin >> id;
student newStudent(name, id);
uni.addStudent(newStudent);
cout << "Student added successfully!" << endl;
}

void addTeacher(University& uni)


{
string name;
int id;
cout << "Enter teacher name: ";
cin.ignore();
getline(cin, name);
cout << "Enter teacher ID: ";
cin >> id;
teacher newTeacher(name, id);
uni.addTeacher(newTeacher);
cout << "Teacher added successfully!" << endl;
}

void enrollStudentInCourse(University& uni)


{
int studentId;
string course;
cout << "Enter student ID: ";
cin >> studentId;
cout << "Enter course name: ";
cin.ignore();
getline(cin, course);
student* student = uni.findStudentById(studentId);
if (student) {
student->enrolCourse(course);
cout << "Student enrolled in course successfully!" << endl;
} else {
cout << "Student not found!" << endl;
}
}

void assignCourseToTeacher(University& uni)


{
int teacherId;
string course;
cout << "Enter teacher ID: ";
cin >> teacherId;
cout << "Enter course name: ";
cin.ignore();
getline(cin, course);
teacher* teacher = uni.findTeacherById(teacherId);
if (teacher) {
teacher->assignCourse(course);
cout << "Course assigned to teacher successfully!" << endl;
} else {
cout << "Teacher not found!" << endl;
}
}

void addFeeForStudent(University& uni)


{
int studentId;
double fee;
cout << "Enter student ID: ";
cin >> studentId;
cout << "Enter fee amount: ";
cin >> fee;
uni.addFee(studentId, fee);
cout << "Fee added successfully!" << endl;
}

void addGradeForStudent(University& uni)


{
int studentId;
string course, grade;
cout << "Enter student ID: ";
cin >> studentId;
cout << "Enter course name: ";
cin.ignore();
getline(cin, course);
cout << "Enter grade: ";
cin >> grade;
uni.addGrade(studentId, course, grade);
cout << "Grade added successfully!" << endl;
}

int main(){
displayWelcomeNote();
University uni;
int choice;
do {
displayMenu();
cin >> choice;

switch (choice) {
case 1:
addStudent(uni);
break;
case 2:
addTeacher(uni);
break;
case 3:
enrollStudentInCourse(uni);
break;
case 4:
assignCourseToTeacher(uni);
break;
case 5:
addFeeForStudent(uni);
break;
case 6:
addGradeForStudent(uni);
break;
case 7:
uni.displayAllStudents();
break;
case 8:
uni.displayAllTeachers();
break;
case 9:
uni.displayAllFees();
break;
case 10:
int studentId;
cout << "Enter student ID: ";
cin >> studentId;
uni.displayTranscript(studentId);
break;
case 11:
cout << "Goodbye!" << endl;
break;
default:
cout << "Invalid choice. Please try again." << endl;
}
} while (choice != 11);

return 0;
}

You might also like