Monday, June 28, 2021

Student Grading System in C++ Using OOP Approach

 A simple student grading system in C++ using Object Oriented Approach I hope you will find my work useful.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website, kindly contact me also at my email address also. Thank you.

My email address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.





Program Listing

// Grading_System.cpp

// Jake Rodriguez Pompeada, MAED-IT, MIT

// www.jakerpomperada.com and www.jakerpomperada.blogspot.com

// jakerpomperada@gmail.com


#include <iostream>

#include <iomanip>

#include <cmath>

#include <string>


#define EXIT_IF(cnd, msg) if(cnd){std::cerr << msg; exit(1);}


class Grader

{

public:

void run();

private:

std::string get_performance(double grade);

};


void Grader::run()

{

constexpr int num_grades = 5;

int num_students = 0, student, grade;

double sum, total_sum = 0.0;


    std::cout << "\n\n";

std::cout << "\tStudent Grading System in C++ Using OOP Approach";

std::cout << "\n\n";

std::cout << "Number of students in the class? ";

std::cin >> num_students;

std::cin.ignore(255, '\n');

EXIT_IF(num_students < 0, "Invalid Input: Please enter a nonnegative integer.");

for (student = 0; student < num_students; ++student)

{

sum = 0.0;

for (grade = 0; grade < num_grades; ++grade)

{

std::cout << "Grade of Student #" << student + 1 << " in Subject " << grade + 1 << ": ";

int tmp;

std::cin >> tmp;

EXIT_IF(tmp < 0, "Invalid Input: Please enter a nonnegative integer.");

sum += tmp;

}

double avg = std::round(sum / num_grades);

std::cout << "\n\n";

std::cout << "Average of Student " << student + 1 << " is : " << avg << "\n";

total_sum += avg;

}

double class_average = total_sum / num_students;

std::cout << std::fixed << std::setprecision(2) <<

"Class Average Grade is : " << class_average << "\n";

std::cout << "Class Performance is " << get_performance(class_average) << "\n";

}


std::string Grader::get_performance(double grade)

{

if (grade < 70)

return "Poor";

else if(grade <= 74)

return "For Improvement";

else if (grade <= 80)

return "Good";

else if (grade <= 90)

return "Very good";

else

return "Excellent";

}


int main()

{

Grader grader;


grader.run();

}



2 comments: