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

It 2nd Year Group 5 c++ Group Assignment(1) (1)

Uploaded by

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

It 2nd Year Group 5 c++ Group Assignment(1) (1)

Uploaded by

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

BULE HORA UNIVERSITY

COLLEGE OF COMPUTING AND INFORMATICS

DEPARTEMENT OF INFORMATION TECHNOLOGY


COURSE: FUNDAMENTAL PROGRAMMING II
ACADEMIC YEAR: 2nd Year 1st Semister
COURSE CODE: ITec2041
PROGRAM: REGULAR
GROUP ASSIGNMENT

GROUP NAME ID No
1.ALAFI TESHOMA……………………Ru0432\16
2.AYANTU MELAKU………………….Ru0502\16
3.GELGELU WABE…………………….Ru0333\16
4.KALID ABDURHMAN……………….Ru0689\16
5.MITIKU AYELE………………………Ru0170\16

SUBMITTED TO:Mr.KELEMU

SUBMITION DATE:22/04/2017

1
BULE HORA,ETHIOPIA
C++ Console Group Assignment:
Student Grade Management System with OOP
Scenario:
You are tasked with developing a Student Grade Management
System for BHU. The system should help teachers manage and
track student grades efficiently. The following features need to
be implemented using OOP principles using c++program:
Student Management:
 Create a Student class with properties such as Name,
StudentID, Class, and other necessary attributes
 Add methods to the Student class for updating student
details.
Grade Management:
 Create a Grade class with properties such as Subject, Score,
and StudentID.
 Add methods to the Grade class for updating and deleting
grades.
Grade Calculation:
 Create a GradeCalculator class with methods to calculate
the average grade for each student, determine the highest
and lowest grades in each subject, and provide a summary
of grades for each class.
User Interaction:
 Implement a console-based menu system to navigate
through the different functionalities.

2
 Use c++ collections (e.g., Vectors) to store instances of
Student and Grade objects.
 Ensure the system can handle multiple students and
subjects, providing accurate calculations.
Requirements: You are expected to
 Use classes and objects to encapsulate data and
functionality.
 Implement inheritance and polymorphism where
appropriate.
 Reuse code by creating methods that can be called fro m
different parts of the application.
 Implement error handling to manage invalid inputs.
 Ensure the application can handle basic operations without
a graphical user interface.
Expected Outcome(Deliverables):
 A C++ console application project file with all the
necessary classes and code.
 A brief report explaining the design, functionality, and
OOP principles used in the system

Creating a STUDENT Grade Management System in C++ using


OOP principle designing classes that encapsulate the necessary
data and functionality. The system is;
 Student Management ,
 Grade Management,
 Grade Calculationand User Interaction

3
 Example Emplementation
Here is a brief examples of how to you might begin coding the
Bhu student grade management system with OOP

#include <iostream>
#include <vector>
#include <string>
#include <iomanip>
#include <algorithm>
#include <limits>
using namespace std;
// Student Class
class Student {
private:
int studentID;
string name;
string department;

public:
// Constructor
Student(int id, string n, string dept) : studentID(id), name(n),
department(dept) {}
// Getters
int getStudentID() const { return studentID; }

4
string getName() const { return name; }
string getDepartment() const { return department; }

// Update student details


void updateDetails(string newName, string newDept) {
name = newName;
department = newDept;
}
// Print student information
void display() const {
cout << "Student ID: " << studentID << ", Name: " <<
name << ", Department: " << department << endl;
}
};
// Grade Class
class Grade {
private:
int studentID;
string subject;
float score;
public:
// Constructor
Grade(int id, string sub, float scr) : studentID(id), subject(sub),
score(scr) {}
// Getters

5
int getStudentID() const { return studentID; }
string getSubject() const { return subject; }
float getScore() const { return score; }
// Update grade details
void updateGrade(float newScore) {
score = newScore;
}
// Display grade
void display() const {
cout << "Student ID: " << studentID << ", Subject: " <<
subject << ", Score: " << score << endl;
}
};
// GradeCalculator Class
class GradeCalculator {
public:
// Calculate average grade for a student
static float calculateAverage(const vector<Grade>& grades,
int studentID) {
float totalScore = 0;
int count = 0;
for (const Grade& grade : grades) {
if (grade.getStudentID() == studentID) {
totalScore += grade.getScore();
count++;

6
}
}
if (count == 0) return 0; // No grades for the student
return totalScore / count;
}
// Find the highest and lowest grades in a subject
static pair<float, float> findHighLowInSubject(const
vector<Grade>& grades, const string& subject) {
float highest = numeric_limits<float>::min();
float lowest = numeric_limits<float>::max();
bool found = false;

for (const Grade& grade : grades) {


if (grade.getSubject() == subject) {
found = true;
highest = max(highest, grade.getScore());
lowest = min(lowest, grade.getScore());
}
}
if (!found) {
return {0, 0}; // No grades for the subject
}
return {highest, lowest};
}
// Provide a summary of grades for each student

7
static void displayGradeSummary(const vector<Student>&
students, const vector<Grade>& grades) {
for (const Student& student : students) {
cout << "Summary for " << student.getName() << " (ID:
" << student.getStudentID() << "):" << endl;
float avg = calculateAverage(grades,
student.getStudentID());
cout << "Average Grade: " << avg << endl;
cout << "--------------------------------------" << endl;
}
}
};
// Main Application
int main() {
vector<Student> students;
vector<Grade> grades;
while (true) {
cout << "\n BHU STUDENT GRADE MANAGEMENT
SYSTEM " << endl;
cout << "1. Add Student" << endl;
cout << "2. Update Student Details" << endl;
cout << "3. Add Grade" << endl;
cout << "4. Update Grade" << endl;
cout << "5. Calculate Average Grade for a Student" <<
endl;

8
cout << "6. Find Highest and Lowest Grades in a Subject"
<< endl;
cout << "7. Display Grade Summary for All Students" <<
endl;
cout << "8. Exit" << endl;
cout << "Enter your choice: ";
int choice;
cin >> choice;
switch (choice) {
case 1: {
// Add a new student
int id;
string name, department;
cout << "Enter Student ID: ";
cin >> id;
cin.ignore();
cout << "Enter Student Name: ";
getline(cin, name);
cout << "Enter Department: ";
getline(cin, department);
students.push_back(Student(id, name, department));
cout << "Student added successfully!" << endl;
break;
}
case 2: {

9
// Update student details
int id;
cout << "Enter Student ID to update: ";
cin >> id;
auto it = find_if(students.begin(), students.end(),
[id](const Student& s) {
return s.getStudentID() == id;
});
if (it != students.end()) {
string newName, newDept;
cin.ignore();
cout << "Enter New Name: ";
getline(cin, newName);
cout << "Enter New Department: ";
getline(cin, newDept);
it->updateDetails(newName, newDept);
cout << "Student details updated successfully!" <<
endl;
} else {
cout << "Student not found!" << endl;
}
break;
}
case 3: {
// Add a grade

10
int id;
string subject;
float score;
cout << "Enter Student ID: ";
cin >> id;
cin.ignore();
cout << "Enter Subject: ";
getline(cin, subject);
cout << "Enter Score: ";
cin >> score;
grades.push_back(Grade(id, subject, score));
cout << "Grade added successfully!" << endl;
break;
}
case 4: {
// Update grade details
int id;
string subject;
cout << "Enter Student ID: ";
cin >> id;
cin.ignore();
cout << "Enter Subject: ";
getline(cin, subject);
auto it = find_if(grades.begin(), grades.end(), [id,
subject](const Grade& g) {

11
return g.getStudentID() == id && g.getSubject() ==
subject;
});
if (it != grades.end()) {
float newScore;
cout << "Enter New Score: ";
cin >> newScore;
it->updateGrade(newScore);
cout << "Grade updated successfully!" << endl;
} else {
cout << "Grade not found!" << endl;
}
break;
}
case 5: {
// Calculate average grade for a student
int id;
cout << "Enter Student ID: ";
cin >> id;

float avg = GradeCalculator::calculateAverage(grades, id);


if (avg == 0) {
cout << "No grades found for the student!" << endl;
} else {
cout << "Average Grade: " << avg << endl;

12
}
break;
}
case 6: {
// Find highest and lowest grades in a subject
string subject;
cin.ignore();
cout << "Enter Subject: ";
getline(cin, subject);
auto [highest, lowest] =
GradeCalculator::findHighLowInSubject(grades, subject);
if (highest == 0 && lowest == 0) {
cout << "No grades found for the subject!" << endl;
} else {
cout << "Highest Grade: " << highest << ", Lowest
Grade: " << lowest << endl;
}
break;
}
case 7: {
// Display grade summary for all students
GradeCalculator::displayGradeSummary(students,
grades);
break;
}

13
case 8: {
// Exit
cout << "Exiting... Goodbye!" << endl;
return 0;
}
default: {
cout << "Invalid choice! Please try again." << endl;
}
}
}

return 0;
}

4 Brief Report:

Student Grade Management System with OOP


Design and Functionality

Design Overview: The Student Grade Management System is


designed to manage student information, grades, and perform
grade calculations efficiently using Object-Oriented
Programming (OOP) principles. The system is composed of
several key components: Student Management, Grade
Management, Grade Calculation, and User Interaction.

Key Components:

Student Class:

14
Properties: StudentID, Name, Grade.

Methods: Getters and setters for each property, a method to


update all details, and a method to display student details.

Functionality: Manages student-related information including


adding, updating, and displaying student details.

Grade Class:

Properties: Subject, Score, StudentID.

Methods: Getters and setters for each property, methods to


update and delete grades, and a method to display grade details.

Functionality: Manages grades for students including adding,


updating, deleting, and displaying grades.

GradeCalculator Class:

Properties: A vector of Grade objects.

Methods: Methods to calculate the average grade for each


student, determine the highest and lowest grades in each subject,
and provide a summary of grades for each class.

Functionality: Performs calculations related to grades, providing


insights into student performance and overall class performance.

User Interaction:

Functionality: Provides a console-based menu system that


allows users to interact with the system, perform CRUD (Create,
Read, Update, Delete) operations on students and grades, and
use the GradeCalculator for various calculations.

Object-Oriented Programming (OOP)


Principles

15
1. Encapsulation: Encapsulation is the concept of bundling the
data (attributes) and methods (functions) that operate on the data
into a single unit, or class. This principle is used extensively in
the system to group related properties and methods within
classes.

Student Class:

Encapsulates student-related data and methods. Provides public


methods (getters and setters) to access and modify private data.

Grade Class:

Encapsulates grade-related data and methods. Ensures data


integrity by providing controlled access to grade properties
through getters and setters.

2. Abstraction: Abstraction involves hiding complex


implementation details and exposing only the necessary features
of an object. The system abstracts the complexity of managing
student and grade data through well-defined interfaces
(methods).

GradeCalculator Class:

Abstracts the process of calculating grades by providing high-


level methods for calculating average grades, finding highest
and lowest grades, and summarizing class performance.

3. Inheritance and Polymorphism: Although the current


implementation does not explicitly use inheritance and
polymorphism, these principles can be incorporated for future
extensions. For example, different types of students (e.g.,
UndergraduateStudent, GraduateStudent) could inherit from a
base Student class, enabling polymorphic behavior.

4. Code Reuse: The system promotes code reuse by defining


methods that can be called from different parts of the application.
For example, methods to update student details or grades can be
reused wherever these updates are needed.

16
5. Error Handling: While the provided code focuses on
functionality, error handling mechanisms are crucial for a robust
system. Implementing input validation and error messages can
ensure that the system handles invalid inputs gracefully and
provides feedback to users.

Conclusion

The Student Grade Management System demonstrates effective


application of OOP principles to create a modular, maintainable,
and scalable application. Encapsulation and abstraction ensure
data integrity and simplify complex operations. The system is
designed to be user-friendly and provides essential
functionalities for managing and tracking student grades
efficiently. Future enhancements could include the use of
inheritance and polymorphism to handle different student types
and more sophisticated error handling to improve system
robustness.

17

You might also like