a grading system c++ code
a grading system c++ code
Group members
Alishba Waris(242047)
Qasim waheed(242128)
Moizullah (241244)
Ali Aman Abbasi (242113)
Introduction:
In the era of the digital age, the task of managing student records and assessing
the performance of students efficiently and precisely has become an essentiality.
This project—Teacher Portal using C++—has the purpose of automating the
computation of student grades from raw data files with quiz, assignment, exam,
and project marks. With the provision for dynamic user entry of weightages, the
program guarantees flexibility and can easily adjust to varying subject
frameworks.
Developed as a part of a Complex Engineering Activity for the Computer
Programming Laboratory, this project promotes abstract thinking and real-world
problem-solving. It applies fundamental programming constructs like file
handling, loops, and conditionals, but with the results being scalable, generic,
and grade-aware according to computed class averages. The system provides
functionality like class-wide result viewing, student-wise searching, and result
exporting in nca.csv and cp.csv format—replicating real administrative portals.
1
Implementation:
Screenshots:
2
3
Code explanation(working):
The program works as follows:
1. File Input:
o Prompts the user to choose a CSV file containing student marks.
o Dynamically detects how many quizzes and assignments are
present based on file headers.
2. User Input for Weightage:
o Asks the user to enter percentage weights for quizzes, assignments,
midterm, final, and project.
o Validates that the total weight is 100%.
3. Data Processing:
o Reads marks for each student.
o Calculates averages for quizzes and assignments.
o Uses the given formula to compute total weighted marks for each
student:
Total Marks=
4
(Quiz Total/Max Quiz Marks)×Quiz Weight+(Assignment Total/Max Assignment
Marks) ×Assignment Weight.
4.Grading:
o Computes the class average.
o Dynamically defines grading bands with the class average as the
centre of a B- range.
o Assigns grades accordingly (e.g., 59-63 = B-, 64-68 = B, etc.).
5.User Menu:
o Option 1: Show entire class results on the console.
o Option 2: Search for a student using roll number and show their
grade.
o Option 3: Export the result to a CSV file.
o Option 4: Exit the program.
Program outputs:
5
Learning outcomes:
Through the completion of this project, we learned how to:
Read and parse data from CSV files with C++.
Organize our program into manageable sections using functions.
Develop error checking, like ensuring that the sum of weight we input
equals 100%.
Learn to apply grading rules based on class performance and average
scores.
Enhance our ability to handle user input/output and store results in CSV
format.
Enhance our problem-solving and thinking capabilities, and learn how to
write neat and well-documented code.
References:
Bjarne Stroustrup, The C++ Programming Language, Addison-Wesley.
Herbert Schildt, C++: The Complete Reference, McGraw-Hill.
Online C++ documentation: https://cplusplus.com
Lecture notes and lab manuals provided in CP Lab sessions.
Stack Overflow discussions and community coding solutions for CSV
parsing.
C++ code:
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstdlib>
6
// Constants for limits
const int MAX_STUDENTS = 100;
const int MAX_ENTRIES = 20;
// Data arrays
string names[MAX_STUDENTS];
string rollNos[MAX_STUDENTS];
float quizzes[MAX_STUDENTS][MAX_ENTRIES];
float assignments[MAX_STUDENTS][MAX_ENTRIES];
float mids[MAX_STUDENTS];
float finals[MAX_STUDENTS];
float projects[MAX_STUDENTS];
float totalMarks[MAX_STUDENTS];
char grades[MAX_STUDENTS];
string line;
7
getline(file, line); // skip header
studentCount++;
8
}
file.close();
cout << "Data successfully read from the file.\n";
return true;
}
9
float qAvg = (quizCount > 0) ? qSum / quizCount : 0;
float aAvg = (assignmentCount > 0) ? aSum / assignmentCount : 0;
// Displaystudent results
void showClassResults() {
cout << "\nName\tRoll No\tTotal\tGrade\n";
10
for (int i = 0; i < studentCount; i++) {
cout << names[i] << "\t" << rollNos[i] << "\t" << totalMarks[i] << "\t" << grades[i] << endl;
}
}
// Main program
int main() {
string fileName;
float quizWeight, assignmentWeight, midWeight, finalWeight, projectWeight;
int fileChoice;
bool fileLoaded = false;
11
while (!fileLoaded) {
cout << "Choose a file to load:\n1. nca.csv\n2. cp.csv\nChoose option: ";
cin >> fileChoice;
if (fileChoice == 1)
fileName = "C:\\Users\\HP\\OneDrive\\Desktop\\New folder\\NCA.csv";
else if (fileChoice == 2)
fileName = "C:\\Users\\HP\\OneDrive\\Desktop\\New folder\\CP.csv";
else {
cout << "Invalid option. Try again.\n";
continue;
}
fileLoaded = readCSVFile(fileName);
if (!fileLoaded) cout << "? File load failed. Try again.\n";
}
int userChoice;
do {
cout << "\nMenu:\n1. Show Class Result\n2. Search Student\n3. Exit\nChoose option: ";
cin >> userChoice;
if (userChoice == 1) showClassResults();
12
else if (userChoice == 2) searchStudentByRollNumber();
else if (userChoice != 3) cout << "Invalid choice. Try again.\n";
return 0;
}
Conclusion:
This Teacher Portal project closes the gap between programming theory and its
practical implementation in school record systems. In reading input from flexible
data files, accepting dynamic user-defined parameters, and generating correct
outputs with context grading, the program demonstrates the complete
capability of C++ in solving real-world issues. As much as technical success, this
project also teaches the value of program scalability, user interaction, and
automation of systems, which are key ingredients for any software engineer.
Students who finish this project are exposed to analytical thinking, modular
design, and automated grading systems—all of which prepare them to tackle
future projects in software development and academic data management.
13