The following code is a partial program for a grading system. Complete the missi
ID: 669687 • Letter: T
Question
The following code is a partial program for a grading system. Complete the missing portion of the code to make the program run.
Problem says this is for a class, rather than one student.
Strategy: Attack for a single student, then do for an array of N students.
Grading Program Policies:
Two quizzes, 10 points each
Midterm and final exam, 100 points each
Of grade, final counts 50%, midterm 25%, quizes25%
Letter Grade is assigned:
90 or more A
80 – 89, B
70 – 79, C
60 – 69, D
Less than 60, F
Input: Read student's scores,
Output: scores + numeric average + assigned letter grade
Use a struct to contain student record.
struct StudentRecord
{
int studentID;
double quiz1;
double quiz2;
double midterm;
double final;
double average;
char grade;
};
//prompts for input for one student, sets the
//structure variable members.
void input(StudentRecord& student);
//calculates the numeric average and letter grade.
void computeGrade(StudentRecord& student);
//outputs the student record.
void output(const StudentRecord student);
int main()
{
StudentRecord student[CLASS_SIZE];
for(int i = 0; i < CLASS_SIZE; i++)
input(student[i]);
for(int i = 0; i < CLASS_SIZE; i++)
{
computeGrade(student[i]);
output(student[i]);
cout << endl;
}
return 0;
}
void input(StudentRecord &student)
{
}
void computeGrade(StudentRecord& student)
{
//final counts 50%, midterm 25%, quizes25%
}
void output(const StudentRecord student)
{
}
Explanation / Answer
#include <bits/stdc++.h>
using namespace std;
#DEFINE CLASS_SIZE 10
struct StudentRecord{
int studentID;
double quiz1;
double quiz2;
double midterm;
double final;
double average;
char grade;
};
void input(StudentRecord& student){
cout << "Enter student ID : ";
cin >> student.studentID;
cout << "Enter Quiz 1 marks out of 20 : ";
cin >> student.quiz1;
cout << "Enter Quiz 2 marks out of 20 : ";
cin >> student.quiz2;
cout << "Enter midterm marks out of 100 : ";
cin >> student.midterm;
cout << "Enter final exam marks out of 100 : ";
cin >> student.final;
}
void computeGrade(StudentRecord& student){
student->average = (2*student->final+student->midterm+student->quiz1+student->quiz2)/4.0;
if (student->average >= 90.0)
student->grade ='A';
else if (student->average >= 80 && student->average < 89)
student->grade = 'B';
else if (student->average >= 70 && student->average < 79)
student->grade = 'C';
else if (student->average >= 60 && student->average < 69)
student->grade = 'D';
else
student->grade = 'F';
}
void output(const StudentRecord student){
cout << "Student ID : " << student.studentID << " Quiz1 : " << student.quiz1 << " Quiz2 : " << student.quiz2 << " MidTerm marks : " << student.midterm << " Final Marks : " << student.final << " average : " << student.average << " grades : " << student.grade << endl;
}
int main(){
StudentRecord student[CLASS_SIZE];
for(int i = 0; i < CLASS_SIZE; i++)
input(student[i]);
for(int i = 0; i < CLASS_SIZE; i++){
computeGrade(student[i]);
output(student[i]);
cout << endl;
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.