Admin MANAGEMENT SYSTEM
Star-uml :
Code :
#include "bits-stdc++.h"
using namespace std;
class Course
{
string name;
vector<int> faculties;
string id;
int credits;
// Map<ScholarID, List of Dates>
map<string, vector<int>> attendance;
public:
Course() {}
Course(const string &courseName, const string &courseId, int courseCredits)
: name(courseName), id(courseId), credits(courseCredits) {}
string getId() const { return id; }
string getName() const { return name; }
// Getter and setter for credits
int getCredits() const { return credits; }
void setCredits(int newCredits) { credits = newCredits; }
// Method to add a faculty to the course
void addFaculty(const int &facultyId) {
bool doesExit = false;
for (auto it = faculties.begin(); it != faculties.end(); it++) {
if (*it == facultyId) {
doesExit = true;
break;
}
}
if (!doesExit) faculties.push_back(facultyId);
vector<int> getFaculties() const {
return faculties;
}
// Method to remove a faculty from the course
void removeFaculty(const int &facultyId)
{
int ind = -1;
for (int i = 0; i < faculties.size(); i++) {
if (faculties[i] == facultyId) {
ind = i;
break;
}
}
if (ind != -1)
faculties.erase(faculties.begin() + ind);
}
// Method to update attendance for a scholar with date
void updateAttendance(const string &scholarId, int date)
{
attendance[scholarId].push_back(date);
}
};
class Faculty
{
public:
int id;
string name;
string department;
Faculty() {}
Faculty(int id, string name, string department) : id(id), name(name), department(department) {}
int getId() const { return id; }
};
class Transaction
{
time_t timestamp;
double amount;
string from;
string to;
string reason;
public:
Transaction(string from, string to, double amount, string reason) : from(from),
to(to), amount(amount), reason(reason),
timestamp(chrono::system_clock::to_time_t(chrono::system_clock::now())) {}
time_t getTimestamp() { return timestamp; }
double getAmount() { return amount; }
string getFrom() { return from; }
string getTo() { return to; }
string getReason() { return reason; }
};
class Registrar {
private:
double balance;
vector<Transaction> transactions;
public:
Registrar(double initialBalance) : balance(initialBalance) {}
// Method to get all transactions
vector<Transaction> getAllTransactions() const {
return transactions;
}
// Method to make a payment
bool makePayment(const string& from, const string& to, const string& reason, double amount) {
if (amount > 0 && amount <= balance) {
balance -= amount;
Transaction newTransaction(from, to, amount, reason);
transactions.push_back(newTransaction);
return true;
}
return false;
}
double getBalance() const {
return balance;
}
};
class Event {
public:
int id;
string name;
double budget;
string coordinator;
bool isBudgetApproved;
Event() {}
Event(int id, string name, string coordinator, double budget) : name(name),
coordinator(coordinator), budget(budget), isBudgetApproved(false),
id(id) {}
int getId() const { return id; }
void editBasicDetails()
{
cout << "Enter New Name: ";
cin.ignore();
getline(cin, name);
cout << "Enter New Coordinator: ";
getline(cin, coordinator);
cout << "Basic details updated successfully." << endl;
}
void updateBudgetApproval()
{
char choice;
cout << "Has the budget been approved? (Y/N): ";
cin >> choice;
isBudgetApproved = (choice == 'Y' || choice == 'y');
cout << "Budget approval status updated." << endl;
}
void requestBudget()
{
}
};
class Student
{
int id;
public:
string name;
string address;
Student() {}
Student(int id, string name, string address) : name(name), address(address), id(id) {}
};
int main()
{
bool run = true;
int choice;
map<string, Course> courses;
map<int, Faculty> faculties;
map<int, Student> students;
map<int, Event> events;
Registrar registrar(10000000000);
while (run)
{
cout << "Welcome to the Menu\n"
"1. Courses\n"
"2. Events\n"
"3. Faculty\n"
"4. Registrar\n"
"5. Student\n"
"6. Dean \n"
"7. Exit\n"
"Choose an option: ";
cin >> choice;
if (choice == 1) {
cout << "Sub menu Options for Courses:\n1. Add Course\n2. Remove Course\n3. Display
Faculties\n4. Exit\nChoose an option: ";
cin >> choice;
if (choice == 1) {
cout << "Adding a course..." << endl;
string courseName, courseId;
int courseCredits;
cout << "Enter Course Name: ";
cin.ignore();
getline(cin, courseName);
cout << "Enter Course ID: ";
cin >> courseId;
cout << "Enter Course Credits: ";
cin >> courseCredits;
Course newCourse(courseName, courseId, courseCredits);
int facultyChoice;
bool addMoreFaculties = true;
while (addMoreFaculties) {
for (auto faculty: faculties) {
cout << faculty.first << "." << faculty.second.name << endl;
}
cout << endl;
cout << "Select Faculty to Add (Enter Faculty ID): ";
cin >> facultyChoice;
// Add selected faculty to the course
if (facultyChoice >= 1 && facultyChoice <= faculties.size()) {
newCourse.addFaculty(faculties[facultyChoice].id);
} else {
cout << "Invalid faculty choice." << endl;
}
cout << "Do you want to add more faculties? (1 for Yes, 0 for No): ";
cin >> addMoreFaculties;
}
courses[newCourse.getId()] = newCourse;
} else if (choice == 2) {
cout << "Removing a course..." << endl;
cout << "Course ID\tCourse Name" << endl;
for (const auto &course : courses) {
cout << course.first << "\t" << course.second.getName() << endl;
}
string courseIdToRemove;
cout << "Enter Course ID to Remove: ";
cin >> courseIdToRemove;
auto it = courses.find(courseIdToRemove);
if (it != courses.end()) {
courses.erase(it);
cout << "Course with ID " << courseIdToRemove << " removed successfully." << endl;
} else {
cout << "Course with ID " << courseIdToRemove << " not found." << endl;
}
} else if (choice == 3) {
cout << "Displaying faculties for selected course..." << endl;
cout << "Select a Course:" << endl;
for (const auto &course : courses) {
cout << course.first << "\t" << course.second.getName() << endl;
}
cout << "Enter choice: ";
string courseChoice;
cin >> courseChoice;
auto it = courses.find(courseChoice);
if (it != courses.end()) {
vector<int> courseFaculties = courses[courseChoice].getFaculties();
for (int facultyID: courseFaculties) {
cout << facultyID << "." << faculties[facultyID-1].name;
}
} else {
cout << "Invalid course choice." << endl;
}
} else if (choice == 4) {
continue;
} else {
cout << "Invalid submenu choice." << endl;
}
} else if (choice == 2) {
cout << "Sub menu Options for Cultural Events\n1. Add Event\n2. Remove Event\n3. Exit\nChoose
an option: ";
cin >> choice;
if (choice == 1)
{
cout << "Creating a new event..." << endl;
int eventId = (int)events.size();
string eventName, coordinatorName;
double eventBudget;
cout << "Enter Event Name: ";
cin.ignore();
getline(cin, eventName);
cout << "Enter Coordinator's Name: ";
getline(cin, coordinatorName);
cout << "Enter Event Budget: $";
cin >> eventBudget;
Event newEvent(eventId, eventName, coordinatorName, eventBudget);
events[eventId] = newEvent;
cout << "Event created." << endl;
}
else if (choice == 2)
{
int removeId;
for (const auto &event : events) {
cout << event.first << "\t" << event.second.name << endl;
}
cout << "Enter the ID of the event to remove: ";
cin >> removeId;
auto it = events.find(removeId);
if (it != events.end())
{
events.erase(it);
cout << "Event with ID " << removeId << " removed successfully." << endl;
}
else
{
cout << "Event with ID " << removeId << " not found." << endl;
}
}
else if (choice == 3)
{
continue;
}
else
{
cout << "Invalid choice. Please try again." << endl;
}
} else if (choice == 3) {
cout << "Sub menu Options for Faculty:\n1. Add Faculty\n2. Remove Faculty\n3. Exit\nChoose an
option: ";
cin >> choice;
if (choice == 1) {
cout << "Adding a new faculty member..." << endl;
int facultyId = (int)faculties.size();
string facultyName, facultyDepartment;
cout << "Enter Faculty Name: ";
cin.ignore();
getline(cin, facultyName);
cout << "Enter Faculty Department: ";
getline(cin, facultyDepartment);
Faculty newFaculty(facultyId, facultyName, facultyDepartment);
faculties[facultyId] = newFaculty;
cout << "Faculty member added successfully." << endl;
} else if (choice == 2) {
cout << "Removing a faculty member..." << endl;
for (auto faculty: faculties) {
cout << faculty.first << "." << faculty.second.name << endl;
}
int removeId;
cout << "Enter Faculty ID to remove: ";
cin >> removeId;
auto it = faculties.find(removeId);
if (it != faculties.end()) {
faculties.erase(it);
} else {
cout << "Faculty with ID " << removeId << " not found." << endl;
}
} else {
cout << "Invalid choice. Please try again." << endl;
}
} else if (choice == 4) {
cout << "Registrar Options:\n1. Show All Transactions\n2. Make Payment\n3. Get Balance\n4.
Exit\nChoose an option: ";
cin >> choice;
if (choice == 1) {
cout << "All Transactions:" << endl;
vector<Transaction> allTransactions = registrar.getAllTransactions();
for ( auto& transaction : allTransactions) {
cout << "From: " << transaction.getFrom() << ", To: " << transaction.getTo()
<< ", Amount: ₹" << transaction.getAmount() << ", Reason: " << transaction.getReason() <<
endl;
}
} else if (choice == 2) {
string from, to, reason;
double amount;
cout << "Enter payer's name: ";
cin >> from;
cout << "Enter payee's name: ";
cin >> to;
cout << "Enter payment amount: $";
cin >> amount;
cin.ignore(); // Ignore newline character
cout << "Enter payment reason: ";
getline(cin, reason);
if (registrar.makePayment(from, to, reason, amount)) {
cout << "Payment successful." << endl;
} else {
cout << "Payment failed due to insufficient balance or invalid amount." << endl;
}
} else if (choice == 3) {
cout << "Current Balance: $" << registrar.getBalance() << endl;
} else if (choice == 4) {
continue;
} else {
cout << "Invalid choice. Please try again." << endl;
}
} else if (choice == 5) {
cout << "Submenu Options for Student:\n1. Add Student\n2. Remove Student\n3. Update Student
Details\n4. Exit\nChoose an option: ";
cin >> choice;
if (choice == 1) {
cout << "Adding a new Student..." << endl;
int studentId = (int)students.size();
string studentName, studentAddress;
cout << "Enter Student Name: ";
cin.ignore();
getline(cin, studentName);
cout << "Enter Student Address: ";
getline(cin, studentAddress);
Student newStudent(studentId, studentName, studentAddress);
students[studentId] = newStudent;
cout << "Student added successfully." << endl;
} else if (choice == 2) {
cout << "Removing a Student..." << endl;
for (auto student: students) {
cout << student.first << "." << student.second.name << endl;
}
int removeId;
cout << "Enter Student ID to remove: ";
cin >> removeId;
auto it = students.find(removeId);
if (it != students.end()) {
students.erase(it);
} else {
cout << "Student with ID " << removeId << " not found." << endl;
}
} else if (choice == 3) {
cout << "Updating student details..." << endl;
for (auto student: students) {
cout << student.first << "." << student.second.name << endl;
}
int updateId;
cout << "Enter Student ID to update details: ";
cin >> updateId;
// Find the faculty member by ID and update the details
for (auto& student: students) {
if (student.first == updateId) {
string newStudentName, newStudentAddress;
cout << "Enter New student Name: ";
cin.ignore();
getline(cin, newStudentName);
cout << "Enter New student Address: ";
getline(cin, newStudentAddress);
student.second.name = newStudentName;
student.second.address = newStudentAddress;
cout << "Student details updated successfully." << endl;
break; // Stop searching after updating the details
}
}
} else {
cout << "Invalid choice. Please try again." << endl;
}
} else if (choice == 6) {
cout << "You chose Dean." << endl;
} else if (choice == 7) {
cout << "Exiting the program..." << endl;
run = false;
} else {
cout << "Invalid choice. Please try again." << endl;
}
cout << endl;
}
}
Output :
<--------------------Admin MANAGEMENT
SYSTEM--------------------->
Welcome to the Menu
1. Courses
2. Events
3. Faculty
4. Registrar
5. Student
6. Dean
7. Exit
Choose an option: 1
Sub menu Options for Courses:
1. Add Course
2. Remove Course
3. Display Faculties
4. Exit
Choose an option: 1
Adding a course...
Enter Course Name: DataStructures
Enter Course ID: CS301
Enter Course Credits: 4
Select Faculty to Add (Enter Faculty ID): 01
Invalid faculty choice.
Do you want to add more faculties? (1 for Yes, 0 for No): 0
Welcome to the Menu
1. Courses
2. Events
3. Faculty
4. Registrar
5. Student
6. Dean
7. Exit
Choose an option: 1
Sub menu Options for Courses:
1. Add Course
2. Remove Course
3. Display Faculties
4. Exit
Choose an option: 3
Displaying faculties for selected course...
Select a Course:
CS301 DataStructures
Enter choice: CS301
Welcome to the Menu
1. Courses
2. Events
3. Faculty
4. Registrar
5. Student
6. Dean
7. Exit
Choose an option: 3
Sub menu Options for Faculty:
1. Add Faculty
2. Remove Faculty
3. Exit
Choose an option: 1
Adding a new faculty member...
Enter Faculty Name: ArupBhatt
Enter Faculty Department: CSE
Faculty member added successfully.
Welcome to the Menu
1. Courses
2. Events
3. Faculty
4. Registrar
5. Student
6. Dean
7. Exit
Choose an option: 1
Sub menu Options for Courses:
1. Add Course
2. Remove Course
3. Display Faculties
4. Exit
Choose an option: 3
Displaying faculties for selected course...
Select a Course:
CS301 DataStructures
Enter choice: CS301
Welcome to the Menu
1. Courses
2. Events
3. Faculty
4. Registrar
5. Student
6. Dean
7. Exit
Choose an option: 5
Submenu Options for Student:
1. Add Student
2. Remove Student
3. Update Student Details
4. Exit
Choose an option: 1
Adding a new Student...
Enter Student Name: Abbas Bahrainwala
Enter Student Address: Guwahati
Student added successfully.
Welcome to the Menu
1. Courses
2. Events
3. Faculty
4. Registrar
5. Student
6. Dean
7. Exit
Choose an option: 5
Submenu Options for Student:
1. Add Student
2. Remove Student
3. Update Student Details
4. Exit
Choose an option: 3
Updating student details...
0.Bipangshu Saha
Enter Student ID to update details: 0
Enter New student Name: Abbas Bahrainwala
Enter New student Address: Pune
Student details updated successfully.
Welcome to the Menu
1. Courses
2. Events
3. Faculty
4. Registrar
5. Student
6. Dean
7. Exit
Choose an option: 6
You chose Dean.
Welcome to the Menu
1. Courses
2. Events
3. Faculty
4. Registrar
5. Student
6. Dean
7. Exit
Choose an option: 4
Registrar Options:
1. Show All Transactions
2. Make Payment
3. Get Balance
4. Exit
Choose an option: 2
Enter payer's name: Bishwa
Enter payee's name: hjj
Enter payment amount: $100
Enter payment reason: Sound System
Payment successful.
Welcome to the Menu
1. Courses
2. Events
3. Faculty
4. Registrar
5. Student
6. Dean
7. Exit
Choose an option: 4
Registrar Options:
1. Show All Transactions
2. Make Payment
3. Get Balance
4. Exit
Choose an option: 3
Current Balance: $1e+10
Welcome to the Menu
1. Courses
2. Events
3. Faculty
4. Registrar
5. Student
6. Dean
7. Exit
Choose an option: 7
Exiting the program...
Program ended with exit code: 0