Letter grades are sometimes assigned to numeric scores by using the grading sche
ID: 641509 • Letter: L
Question
Letter grades are sometimes assigned to numeric scores by using the grading scheme commonly known as grading on the curve. In this scheme, a letter grade is assigned to a numeric score as follows (where m is the mean grade and sd is the standard deviation):
Numeric Score Letter Grade
between 0.5 and 1.5 * sd below mean D
between 0.5*sd below and 0.5*sd above mean C
between 0.5 and 1.5*sd above mean B
>1.5*sd above mean A
The mean is the sum of all the scores divided by the number of scores.
A simplified formula for standard deviation is
where x is an individual score, m is the mean, and n is the number of scores.
Write a program to read in a list of real numbers, representing numeric scores - storing them in a static array, or a dynamic array (created using new), call functions to calculate the mean and standard deviation, and then call a function to calculate and display the letter grade and corresponding numeric score.
Explanation / Answer
Program code:
#include <iostream>
#include <math.h>
using namespace std;
//method prototypes
double computeMean(double *score, int n);
double computeStandardMean(double *score, int n, double mean);
void computeDisplay(double *scores,double mean,double sd,int n);
//main function
int main()
{
int n;
double *scores;
cout << "Enter the size of the array of scores: ";
cin>>n;
cout<<"Enter the scores: "<<endl;
//dynamic array allocation
scores=new double[n];
//store the array values
for(int i=0; i<n; i++)
{
cout<<"score "<<(i+1)<<": ";
cin>>scores[i];
}
//call of the functions
double mean=computeMean(scores, n);
cout<<"Mean: "<<mean<<endl;
double stdDeviation=computeStandardMean(scores, n, mean);
cout<<"Standard deviation: "<<stdDeviation<<endl;
computeDisplay(scores, mean, stdDeviation, n);
return 0;
}
//computeMean will compute the mean of the scores and returns the value
double computeMean(double *score, int n)
{
double m=0;
for(int i=0; i<n; i++)
{
m+=score[i];
}
double mean=m/(n*1.0);
return mean;
}
//computeStandardMean will compute the standard deviation of the scores and returns the value
double computeStandardMean(double *score, int n, double mean)
{
double m=0;
for(int i=0; i<n; i++)
{
m+=pow((score[i]-mean), 2);
}
double average=m/n;
double stddev=pow(average, 0.5);
return stddev;
}
//computeDisplay will computes and displays the grades of the scores
void computeDisplay(double *scores,double mean,double sd,int n)
{
cout<<"Numeric Score Letter Grade"<<endl;
for(int i=0; i< n; i++)
{
if(scores[i]>= 0.5 && scores[i]<1.5)
cout<<" "<<scores[i]<<" "<<"D"<<endl;
else if(scores[i]>=1.5 && scores[i]<0.5*sd)
cout<<" "<<scores[i]<<" "<<"C"<<endl;
else if(scores[i]>=0.5*sd && scores[i]<1.5*sd)
cout<<" "<<scores[i]<<" "<<"B"<<endl;
else if(scores[i]>=1.5*sd )
cout<<" "<<scores[i]<<" "<<"A"<<endl;
}
}
Sample output:
Enter the size of the array of scores: 5
Enter the scores:
score 1: 12.5
score 2: 63.4
score 3: 89.4
score 4: 67.4
score 5: 38.5
Mean: 54.24
Standard deviation: 26.3943
Numeric Score Letter Grade
12.5 C
63.4 A
89.4 A
67.4 A
38.5 B
Note: Please the values while displaying, the information given to check the conditions are containing the ambiguity.
So, some assumeption is made and the grades are assigned.
Please check it.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.