write a complete C++ program to perform an analysis of ex scores. The input to t
ID: 3889738 • Letter: W
Question
write a complete C++ program to perform an analysis of ex scores. The input to the program is a sequence of N ex scores, followed by -1. Example:
Your program may assume there is at least one ex score in the input sequence, i.e. N > 0. Also assume the ex scores are valid, i.e. in the range 0..100, inclusive. Finally, assume the sequence is always followed by a -1 to denote the end of the sequence --- do not include the -1 in the analysis.
The output from your program is an analysis of the ex scores: the # of scores, average, max, min, and a histogram of A, B, C, D, and F scores (assuming a standard 90-80-70-60 scale). For example, given the input sequence shown above, the output from your program should be the following:
Explanation / Answer
#include <iostream>
using namespace std;
int main()
{
// your code goes here
int sum=0;
int n=0,a[10],i=0;
int A=0,B=0,C=0,D=0,E=0;
int max=0,sum=0,min=100,avg=0;
cout<<"Sequence of N";
while(a[i]!=-1)
{
cin>>a[i];
n++;
sum=sum+a[i];
if(max<a[i])
max=a[i];
if(min>a[i])
min=a[i];
if(a[i]>90&&a[i]<100)
A++;
else if(a[i]>80&&a[i]<90)
B++;
else if(a[i]>70&&a[i]<80)
C++;
else if(a[i]>60&&a[i]<70)
D++;
else
E++;
i++;
}
avg=sum/n;
cout<<"# Scores 7 ";
cout<<" Average:"<<avg;
cout<<" Max:"<<max;
cout<<" Min"<<min;
cout<<" 90-100: "<<A;
cout<<" 80-90: "<<B;
cout<<" 70-80:"<<C;
cout<<" 60-70:"<<D;
cout<<" <60:" << E;
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.