Project UAMS
UAMS
Session: 2024-2028
Submitted by:
Muhammad Sami Mughal 2024-CS-831
Supervised by:
Mr. Talha
Computer Science
University of Engineering and Technology Lahore
Pakistan
Muhammad Sami Mughal 2024-CS-831
Project UAMS
Major parts of my Project
Description:
This program manages student data, including adding, viewing, updating, and
deleting records. It calculates student aggregates based on Matric, Inter, and ECAT marks and
saves or loads data from a file. A login system verifies user credentials before accessing the
menu, where users can select options for various operations. Submenus allow detailed editing,
and the header displays an animated logo for presentation.
Users of Application:
The user can perform several tasks in this program;
Add, View, Update, and Delete Students:
Users can manage student
records, including name, registration number, and department.
Calculate Aggregate:
Users can calculate and view the aggregate
percentage based on Matric, Inter, and ECAT marks.
Save and Load Data:
Users can save student data to a file or load it
back for future use.
Functional Requirements:
Login System:
Verifies user credentials before accessing the
program.
Student Management:
Allows adding, viewing, updating, and deleting
student records.
Aggregate Calculation:
Computes aggregate percentage using Matric,
Inter, and ECAT marks.
File Handling:
Saves and retrieves student data from a file for
persistent storage.
Muhammad Sami Mughal 2024-CS-831
Project UAMS
Source Code of UAMS
#include <iostream>
#include <fstream>
#include <windows.h>
using namespace std;
int menu();
void header();
void view();
void del();
void preferences();
void update();
void add();
void submenu(int studentId); // Submenu for editing a specific student
float aggregate(float metric, float inter, float ecat);
void calculateAggregate();
bool login();
void saveToFile();
void loadFromFile();
string names[100]; // Array to store names of students
int reg[100]; // Array to store registration numbers of students
string departments[100]; // Array to store departments of students
float aggregates[100]; // Array to store aggregates of students
int studentCount = 0; // Counter to keep track of the number of students added
int main()
{
Muhammad Sami Mughal 2024-CS-831
Project UAMS
if (!login()) {
cout << "Invalid credentials. Exiting program..." << endl;
return 0;
}
loadFromFile(); // Load data from file
int option;
header();
Sleep(2000);
while (true)
{
option = menu();
Sleep(2000);
if (option == -1) ;
if(option == 1)
{
add();
Sleep(2000);
// Automatically go to submenu after adding data
int studentId = studentCount; // Latest added student ID
submenu(studentId); // Call submenu to edit the latest student
Muhammad Sami Mughal 2024-CS-831
Project UAMS
Sleep(2000);
}
else if(option == 2)
{
view();
Sleep(5000);
}
else if(option == 3)
{
del();
Sleep(2000);
}
else if(option == 4)
{
update();
Sleep(2000);
}
else if(option == 5)
{
preferences();
Sleep(2000);
}
else if(option == 6) // Aggregate option
{
calculateAggregate();
Sleep(2000);
}
else
Muhammad Sami Mughal 2024-CS-831
Project UAMS
{
cout << "Invalid Option" << endl;
Sleep(2000);
}
}
saveToFile(); // Save data to file
return 0;
}
bool login() {
string username, password;
cout << "Enter Username: ";
cin >> username;
cout << "Enter Password: ";
cin >> password;
return (username == "sami" && password == "1724");
}
void header() {
system("cls");
system("color 02");
cout << "### ### ## #### #### #################\n";
cout << "### ### ## ## ##### #####
#################\n";
cout << "### ### ### ### ### ### ### ### ### \n";
Muhammad Sami Mughal 2024-CS-831
Project UAMS
cout << "### ### ### ### ### ### ### ### ### \n";
cout << "### ### ############## ### ### ### ###
#################\n";
cout << "### ### ### ### ### ##### ###
#################\n";
cout << "### ### ### ### ### ### ### ###\n";
cout << " ### ### ### ### ### ### ###\n";
cout << " ### ### ### ### ### ### #################\n";
cout << " ###### ### ### ### ### #################\n";
Sleep(3000);
}
int menu()
{
system("cls");
int option;
cout << "--------------------------------------------\n";
cout << " MENU \n";
cout << "--------------------------------------------\n";
cout << "1. ADD\n";
cout << "2. VIEW\n";
cout << "3. DELETE\n";
cout << "4. UPDATE\n";
cout << "5. PREFERENCES\n";
cout << "6. CALCULATE AGGREGATE\n"; // New option for aggregate calculation
cout << "Enter an option (-1 to exit): ";
cin >> option;
return option;
}
Muhammad Sami Mughal 2024-CS-831
Project UAMS
void preferences()
{
system("cls");
string select;
cout << "Following are some options of campuses you have:" << endl;
cout << "UET Lahore" << endl;
cout << "UET Faisalabad" << endl;
cout << "UET Texila" << endl;
cout<< "UET Grw Campus "<<endl;
cout<< "UET Narowal Campus"<<endl;
cout << "Select one: ";
cin >> select;
cout << "Thank you for applying to " << select << endl;
}
void view()
{
system("cls");
if (studentCount > 0) {
for (int i = 0; i < studentCount; i++) {
cout << "Student " << (i + 1) << " Name: " << names[i] << endl;
cout << "Registration Number: " << reg[i] << endl;
cout << "Department: " << departments[i] << endl;
cout << "Aggregate: " << aggregates[i] << "%" << endl << endl;
}
} else {
cout << "No student data available." << endl;
Muhammad Sami Mughal 2024-CS-831
Project UAMS
}
}
void add()
{
system("cls");
if (studentCount >= 100) {
cout << "Maximum student limit reached!" << endl;
return;
}
cout << "Enter name of student #" << (studentCount + 1) << ": ";
cin >> names[studentCount];
cout << "Enter registration number of student #" << (studentCount + 1) << ": ";
cin >> reg[studentCount];
cout << "Enter department of student #" << (studentCount + 1) << ": ";
cin >> departments[studentCount];
aggregates[studentCount] = 0.0; // Default aggregate
studentCount++; // Increment student count after adding the student
cout << "Student added successfully." << endl;
}
void del()
{
system("cls");
Muhammad Sami Mughal 2024-CS-831
Project UAMS
if (studentCount == 0) {
cout << "No student records available to delete." << endl;
return;
}
int studentId;
cout << "Enter the student number to delete (1 to " << studentCount << "): ";
cin >> studentId;
if (studentId < 1 || studentId > studentCount) {
cout << "Invalid student number!" << endl;
return;
}
// Shift data to overwrite the deleted record
for (int i = studentId - 1; i < studentCount - 1; i++) {
names[i] = names[i + 1];
reg[i] = reg[i + 1];
departments[i] = departments[i + 1];
aggregates[i] = aggregates[i + 1];
}
studentCount--; // Decrement the student count
cout << "Student record deleted successfully." << endl;
}
void update()
{
Muhammad Sami Mughal 2024-CS-831
Project UAMS
system("cls");
int studentId;
cout << "Enter the student number to update (1 to " << studentCount << "): ";
cin >> studentId;
if (studentId < 1 || studentId > studentCount) {
cout << "Invalid student number!" << endl;
return;
}
cout << "Enter new name for student #" << studentId << ": ";
cin >> names[studentId - 1];
cout << "Enter new registration number for student #" << studentId << ": ";
cin >> reg[studentId - 1];
cout << "Enter new department for student #" << studentId << ": ";
cin >> departments[studentId - 1];
cout << "Student details updated successfully." << endl;
}
void submenu(int studentId)
{
system("cls");
string editValue;
cout << "\n------------------------------\n";
cout << " SUB MENU \n";
Muhammad Sami Mughal 2024-CS-831
Project UAMS
cout << "------------------------------\n";
cout << "Do you want to edit the name of student #" << studentId << "? (Yes/No): ";
cin >> editValue;
if (editValue == "Yes") {
cout << "Enter new name for student #" << studentId << ": ";
cin >> names[studentId - 1];
cout << "Enter new registration number for student #" << studentId << ": ";
cin >> reg[studentId - 1];
cout << "Enter new department for student #" << studentId << ": ";
cin >> departments[studentId - 1];
cout << "Student #" << studentId << " details updated." << endl;
}
}
void calculateAggregate()
{
system("cls");
if (studentCount == 0) {
cout << "No student data available to calculate aggregate." << endl;
return;
}
int studentId;
cout << "Enter the student number to calculate aggregate (1 to " << studentCount << "): ";
cin >> studentId;
Muhammad Sami Mughal 2024-CS-831
Project UAMS
if (studentId < 1 || studentId > studentCount) {
cout << "Invalid student number!" << endl;
return;
}
int matric, inter, ecat;
cout << "Enter Matric Marks: ";
cin >> matric;
cout << "Enter Inter Marks: ";
cin >> inter;
cout << "Enter ECAT Marks: ";
cin >> ecat;
aggregates[studentId - 1] = aggregate(matric, inter, ecat);
cout << "Aggregate for student #" << studentId << " calculated successfully." << endl;
}
float aggregate(float metric, float inter, float ecat)
{
float aggregate = (metric / 1100.0) * 17 + (inter / 550.0) * 50 + (ecat / 400.0) * 33;
return aggregate;
}
void saveToFile() {
ofstream file("students.txt");
if (!file) {
cout << "Error saving data to file." << endl;
Muhammad Sami Mughal 2024-CS-831
Project UAMS
return;
}
file << studentCount << endl;
for (int i = 0; i < studentCount; i++) {
file << names[i] << endl;
file << reg[i] << endl;
file << departments[i] << endl;
file << aggregates[i] << endl;
}
cout << "Data saved successfully to students.txt" << endl;
}
void loadFromFile() {
ifstream file("students.txt");
if (!file) {
cout << "No data found. Starting fresh." << endl;
return;
}
file >> studentCount;
file.ignore(); // To skip the newline after the studentCount integer
for (int i = 0; i < studentCount; i++) {
getline(file, names[i]); // Read name
file >> reg[i]; // Read registration number
Muhammad Sami Mughal 2024-CS-831
Project UAMS
file.ignore(); // Skip the newline after the integer
getline(file, departments[i]); // Read department
file >> aggregates[i]; // Read aggregate
file.ignore(); // Skip the newline after the float
}
cout << "Data loaded successfully from students.txt" << endl;
}
Wireframes:
Fig 1: Username/Password
Fig 2: Interface
Fig 3: Main Menu
Muhammad Sami Mughal 2024-CS-831
Project UAMS
Fig 4: Adding data
Fig 5: Viewing data
Fig 6: Deleting data
Fig 7: Updating data
Muhammad Sami Mughal 2024-CS-831
Project UAMS
Fig 8: Preferences
Fig 9: Calculating Aggregate
Data Structures:
Arrays are used to store student data, including names, registration
numbers, departments, and aggregates. Each array holds data for multiple students, indexed by
their entry order. This helps manage and retrieve student information efficiently.
Functions Prototypes:
Function prototypes are declared at the start to define the structure and
purpose of each function in the program. They allow the main function and others to call these
functions before their full definitions. This helps organize the code and improves readability.
Here are examples of function prototypes used in the program:
1. void header();: Declares a function to display the program's animated header.
2. int menu();: Declares a function to display the menu and return the user's chosen
option.
3. float aggregate(float metric, float inter, float ecat);: Declares a
function to calculate the aggregate based on Matric, Inter, and ECAT marks.
Muhammad Sami Mughal 2024-CS-831
Project UAMS
Program Working Flow:
Start
Username/ Main Menu
Password
Adding data Viewing data
Preferences Aggregate
calculator
Deleting data Updating data
Muhammad Sami Mughal 2024-CS-831
Project UAMS
Weakness in the Business Application:
My Program is not very efficient. I should add
more functionalities in my program.
Future Directions:
I will try to add more functions in my program and try to expand it so
that it will meet the requirements of the user. I also will try to make my program more
effective and efficient.
… …
Muhammad Sami Mughal 2024-CS-831