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

//Header Files #include <iomanip> #include <string> #include <fstream> #include

ID: 3610517 • Letter: #

Question

//Header Files

#include <iomanip>

#include <string>

#include <fstream>

#include <iostream>

using namespace std;

int main()

{

//The Start of the main function

//variable declaration. use 8 because its the number of groupst hatthe grades are sorted into

int counter[8],score,i;

//for infile

ifstream infile;

//For loop

for(i=0;i<8;i++)

counter[i]=0;

//opening the file and inputing the score

infile.open("input.txt");

infile >> score;

//-200 indicates end of text file

//reading scores fromf ile

while (score!=200)               // if i just comment this out it will run butits this # here the -999. the rest of the while                                              loopappears fine.

{

i=score/25;

if(i==8)

i--;

counter[i]++;

infile >>score;

} // end while

//variables for ranges

int first=0, last=24;

//For loop

//Outputing scores between ranges

for(i=0;i<8;i++)

{

//Displaying the results

cout << "The Score Between" << first <<"-" << last << endl<< "Is: " <<counter[i] << endl;

first=last+1;

last=first+24;

//If Statment

if(i==6)

last++;

} // end of forloop

//closes the infile

infile.close();

//system pause

system("pause");

return 0;

} //end main

Explanation / Answer

please rate - thanks I changed the code to check for -999, I also added -999 to the datafile and it works fine. My guess is you didn't add the -999(sentinel) to the data file code // Header Files #include #include #include #include using namespace std; int main() { // The Start of the main function // variable declaration. use 8 because its the number of groupsthat the grades are sorted into int counter[8], score,i; // for infile ifstream infile; // For loop for(i=0;i> score; //-200 indicates end of text file //reading scores fromf ile while (score!=-999)   // if ijust comment this out it will run but its this # here the -999. therest of the while loop looks fine { i=score/25; if(i==8) i--; counter[i]++; infile >> score; } // end while //variables for ranges int first=0, last=24; // For loop //Outputing scores between ranges for(i=0;i