0% found this document useful (0 votes)
10 views4 pages

Case Study Problem Idea Class Grades

The document describes a problem to create a program that calculates final grades for students. The program takes input on number of students, assignment weights and scores, midterm and final exam scores. It calculates final grades using arrays, loops, functions, and decision structures. It outputs each student's final grade and the class average grade.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views4 pages

Case Study Problem Idea Class Grades

The document describes a problem to create a program that calculates final grades for students. The program takes input on number of students, assignment weights and scores, midterm and final exam scores. It calculates final grades using arrays, loops, functions, and decision structures. It outputs each student's final grade and the class average grade.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Problem: "Grade Calculator" You are tasked with creating a program that calculates the final grades of a

class of students. The program should take input from the user, including the number of students in the
class, the weightage of each assignment, and the scores obtained by each student for each assignment.
The program should then calculate the final grades for each student and output them to the user.

The grading system should be as follows:

 Assignments are worth 50% of the final grade

 The midterm exam is worth 25% of the final grade

 The final exam is worth 25% of the final grade

The program should take the following inputs from the user:

 The number of students in the class

 The weightage of each assignment (as a percentage)

 The scores obtained by each student for each assignment

 The scores obtained by each student for the midterm exam

 The scores obtained by each student for the final exam

The program should use the following components:

 5 input statements to get the necessary input from the user

 2 decision-making constructs (1 of which should be a nested if-else or a switch) to determine the


final grade for each student based on their scores

 1 array (one-dimensional or multi-dimensional) to store the scores obtained by each student for
each assignment

 2 loop structures (1 of which is a nested loop) to iterate through the array and calculate the final
grade for each student

 2 functions: one to calculate the final grade for a single student based on their scores, and
another to calculate the class average grade.

Once the program has calculated the final grades for each student, it should output the following
information:

 The final grade for each student

 The class average grade

The program should make use of input/output constructs, mathematical operators, string manipulation,
decision-making structures, loop structures, and functions in order to solve the problem.
#include <iostream>

#include <cstdlib>

using namespace std;

// Function to calculate the final grade for a single student

float calculateGrade(float assignmentScores[], float midtermScore, float finalScore, float


assignmentWeight) {

float assignmentTotal = 0;

for (int i = 0; i < 5; i++) {

assignmentTotal += assignmentScores[i];

float assignmentAvg = assignmentTotal / 5;

float assignmentTotalWeight = assignmentAvg * (assignmentWeight / 100);

float midtermWeight = midtermScore * 0.25;

float finalWeight = finalScore * 0.25;

float finalGrade = assignmentTotalWeight + midtermWeight + finalWeight;

return finalGrade;

int main() {

int numStudents;

float assignmentWeight;

float assignmentScores[10][5];

float midtermScores[10];

float finalScores[10];

float finalGrades[10];

float classAvg = 0;
// Get input from the user

cout << "Enter the number of students in the class: ";

cin >> numStudents;

cout << "Enter the weightage of each assignment (as a percentage): ";

cin >> assignmentWeight;

for (int i = 0; i < numStudents; i++) {

// Get assignment scores for each student

cout << "Enter the assignment scores for student " << i + 1 << " (out of 10): ";

for (int j = 0; j < 5; j++) {

cin >> assignmentScores[i][j];

// Get midterm score for each student

cout << "Enter the midterm score for student " << i + 1 << ": ";

cin >> midtermScores[i];

// Get final score for each student

cout << "Enter the final score for student " << i + 1 << ": ";

cin >> finalScores[i];

// Calculate final grade for each student and store in array

finalGrades[i] = calculateGrade(assignmentScores[i], midtermScores[i], finalScores[i],


assignmentWeight);

classAvg += finalGrades[i];

// Calculate class average grade

classAvg = classAvg / numStudents;


// Output final grades for each student and class average grade

for (int i = 0; i < numStudents; i++) {

cout << "Final grade for student " << i + 1 << " is " << finalGrades[i] << endl;

cout << "Class average grade is " << classAvg << endl;

return 0;

You might also like