In: Computer Science
(Write a program in C++)
A local instructor wants you to write a program to calculate the average score made on exams by her students. For simplicity, she always has only 12 students in each course she teaches. She teaches multiple subjects so she would like to enter the name of the exam. She wants the program to also determine the highest and lowest scores and the number of students who passed and failed the exam. A score of 60 or above is considered passing. Also determine the number of scores that were an A (90 or better), B (80 – 89), C (70 – 79), D (60 – 69), or F (below 60).
• Use main( ) as the driver function. Allow the user to process as many exams as desired.
1. Write a function to prompt the user for the following information:
(a) The name of the exam.
(b) The 12 integer scores ranging from 0 to 100. (Store these scores in a one-dimensional array.
Perform input/data validation.)
2. Write a function to determine the highest and lowest score. (Hint: Code is in your etext section:
Finding the Highest and Lowest Values in a Numeric Array)
3. book or see assignment #1.)
4. Write a function to calculate the average score for the exam. (Hint: Code is in your etext section:
Finding the Highest and Lowest Values in a Numeric Array)
5. Write a function to determine the number of students who passed and failed the exam.
6. Write a function to determine the number of scores represented by each letter grade in a standard 10-
point grading scale.
7. Write a function to display the exam’s name, all 12 scores recorded on the exam, the average score,
the highest and lowest score, the number of students who passed and failed the exam, and number of scores that were represented by each letter grade in the standard 10-point grading scale. Display the average to a hundredth of a decimal.
#include <iostream>
#include <string>
using namespace std;
class students{
public:
string examName;
int scores[12];
void getDetails(){
cout<<"Enter the ExamName:";
cin>>examName;
cout<<"Enter the scores of each student\n";
for(int i=0;i<12;i++){
cout<<"Enter the score of student "<<(i+1)<<": ";
cin>>scores[i];
}
}
int* highAndLow(){
int min=scores[0];
int max=scores[0];
cout<<"highAndLow";
for(int i=0;i<12;i++){
if(min>scores[i]){
min=scores[i];
}
if(max<scores[i]){
max=scores[i];
}
}
int* a[]=new int[2];
a[0]=min;
a[1]=max;
return a;
}
double avgScore(){
double avg=0;
cout<<"avgScore";
for(int i=0;i<12;i++){
avg=avg+scores[i];
}
avg=avg/12;
return avg;
}
int* passAndFail(){
int pass=0;
int fail=0;
cout<<"passAndFail";
for(int i=0;i<12;i++){
if(scores[i]>=60){
pass=pass+1;
}
else{
fail=fail+1;
}
}
int* arr[]=new int[2];
arr[0]=pass;
arr[1]=fail;
return arr;
}
int* noOfScoresGrading(){
int A=0,B=0,C=0,D=0,F=0;
cout<<"noOfScoresGrading";
for(int i=0;i<12;i++){
int n=scores[i];
if(n>=90){A++;}
else if(n>=80&&n<=89){B++;}
else if(n>=70&&n<=79){C++;}
else if(n>=60&&n<=69){D++;}
else{F++;}
}
int* arr[]=new int[5];
arr[0]=A;
arr[1]=B;
arr[2]=C;
arr[3]=D;
arr[4]=F
return arr;
}
void display(){
int a[]=highAndLow();
int b=avgScore();
int p[]=passAndFail();
int g[]=noOfScoresGrading();
cout<<"Examname:"<<examName;
cout<<"\nScores of each student is:";
for(int i=0;i<12;i++){
cout<<"\nStudent "<<(i+1)<<" Score:"<<scores[i];
}
cout<<"\nThe highest score is:"a[1];
cout<<"\nThe lowest score is:"+a[0];
cout<<"\nThe number of students who passed:"+p[0];
cout<<"\nThe number of students who failed:"+p[1];
cout<<"\nThe average score is:"<<b;
cout<<"\nNumber of students of Grade:A is:"+g[0];
cout<<"\nNumber of students of Grade:B is:"+g[1];
cout<<"\nNumber of students of Grade:C is:"+g[2];
cout<<"\nNumber of students of Grade:D is:"+g[3];
cout<<"\nNumber of students of Grade:F is:"+g[4];
}
};
int main()
{
students s;
s.getDetails();
s.highAndLow();
s.avgScore();
s.passAndFail();
s.noOfScoresGrading();
s.display();
return 0;
}
Thank you! if you have any queries post it below in the comment
section I will try my best to resolve your queries and I will add
it to my answer if required. Please give upvote if you like
it.