Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that reads a file consisting of students%u2019 test scores in th

ID: 3539758 • Letter: W

Question

Write a program that reads a file consisting of students%u2019 test scores in the

range 0%u2013200. It should then determine the number of students having

scores in each of the following ranges: 0%u201324, 25%u201349, 50%u201374, 75%u201399,

100%u2013124, 125%u2013149, 150%u2013174, and 175%u2013200. Output the score ranges

and the number of students. (Run your program with the following input

data: 76, 89, 150, 135, 200, 76, 12, 100, 150, 28, 178, 189, 167, 200,

175, 150, 87, 99, 129, 149, 176, 200, 87, 35, 157, 189.)

do not use input output file!!!! write code in c++ which should compile in visual studio 2010, else i will not rate!! thanks!!

Explanation / Answer

#include<iostream>
#include<fstream>
using namespace std;
// For this program, I will open a text file where everything is stored, but I won't output the data in a separate file

int main ()
{
ifstream grade;
grade.open("testscores.txt");
int score;
int range[7]={0};
grade>>score;
while (!grade.eof)
{
if (score>=0 && score<=24)
range[0]++;
else if (score>=25 && score<=49)
range[1]++
else if (score>=50 && score<=74)
range[2]++
else if (score>=75 && score<=99)
range[3]++
else if (score>=100 && score<=124)
range[4]++
else if (score>=125 && score<=149)
range[5]++
else if (score>=150 && score<=174)
range[6]++
else if (score>=175 && score<=200)
range[7]++
else
cout<<"Error"<<endl;

grade>>score;
} // end while
cout<<range[0]<<" students have scores between 0 and 24"<<endl;
cout<<range[1]<<" students have scores between 25 and 49"<<endl;
cout<<range[2]<<" students have scores between 50 and 74"<<endl;
cout<<range[3]<<" students have scores between 75 and 99"<<endl;
cout<<range[4]<<" students have scores between 100 and 24"<<endl;
cout<<range[5]<<" students have scores between 125 and 149"<<endl;
cout<<range[6]<<" students have scores between 150 and 174"<<endl;
cout<<range[7]<<" students have scores between 175 and 200"<<endl;


grade.close();
return 0;
}