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

This is a revision of a previous exercise, here is the question: Perform exercis

ID: 3676415 • Letter: T

Question

This is a revision of a previous exercise, here is the question:

Perform exercise 4 at the end chapter 8 of your textbook using dynamic arrays. (This time the program must use dynamic arrays)

C++: Write a program that reads a file consisting of students’ test scores in the range 0-200. It should then determine the number of students having scores in each of the following ranges: 0-24, 25-49, 50-74, 75-99, 100-124, 125-149, 150-174, and 175-200. 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.)

Here is the data file: Scores.txt

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

The OUTPUT should look like this:   

Enter the file name: Scores.txt

The test scores stored in the file:

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

Number of test scores stored in the file: 26

The results about score ranges and number of students in each range:

Number of students between the range of scores 0-24: 1

Number of students between the range of scores 25-49: 2

Number of students between the range of scores 50-74: 0

Number of students between the range of scores 75-99: 6

Number of students between the range of scores 100-124: 1

Number of students between the range of scores 125-149: 3

Number of students between the range of scores 150-174: 5

Number of students between the range of scores 175-200: 8

Special Note: The program needs to be run on dynamic arrays. This must be on C++ format and it needs to be a working code with Comments (I would appreciate it even if the comments are in the dynamic array parts only). I would truly, truly appreciate the help to get this solve, I’ve been stressing since I am really lost on dynamic arrays.

Explanation / Answer

#include<iostream.h>
#include<conio.h>
#include<fstream.h>

void main()
{
   int c=0,s=0,n,r1=0,r2=0,r3=0,r4=0,r5=0,r6=0,r7=0,r8=0;
   ifstream f;
   f.open("Numbers.txt");

   int i=0;
   while(f)
   {
       c++;
       f>>n;
       if(n>=0 && n<=24)
           r1++;

       if(n>=25 && n<=49)
           r2++;
       if(n>=50 && n<=74)
           r3++;

       if(n>=75 && n<=99)
           r4++;

       if(n>=100 && n<=124)
           r5++;

       if(n>=125 && n<=149)
           r6++;

       if(n>=150 && n<=174)
           r7++;

       if(n>=175 && n<=200)
           r8++;
           getch();
   }
   cout<<"Number of test scores stored in the file:"<<c<<endl;

   cout<<"The results about score ranges and number of students in each range:"<<endl;

   cout<<"Number of students between the range of scores 0-24: "<<r1<<endl;

   cout<<"Number of students between the range of scores 25-49: "<<r2<<endl;
   cout<<"Number of students between the range of scores 50-74: "<<r3<<endl;
   cout<<"Number of students between the range of scores 75-99: "<<r4<<endl;
   cout<<"Number of students between the range of scores 100-124: "<<r5<<endl;
   cout<<"Number of students between the range of scores 125-149: "<<r6<<endl;
   cout<<"Number of students between the range of scores 150-174: "<<r7<<endl;
   cout<<"Number of students between the range of scores 175-200: "<<r8<<endl;
   getch();
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote