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

roject objective: write a program that takes a list of final scores for a class

ID: 3784484 • Letter: R

Question

roject objective: write a program that takes a list of final scores for a class and determines: 1) the mean (Greek letter mu), 2) the standard deviation (Greek letter sigma), and 3) the number of grades in each category (A, A-, B+, B-, C+, C, C-, D+, D, and F). See above for the due date.

Use the following formulas for the standard deviation and mean, respectively.

   

Prompt the user for the name of a file containing the final scores, up to 100 scores, such as (without the commas):

100, 94, 59, 83, 57, 11, 92, 76, 37, 89, 74, 59, 65, 79, 49, 89, 89, 75, 64, 82, 15, 74, 82, 68, 92, 61, 33, 95, 91, 82, 89, 64, 43, 93, 86, 65, 72, 40, 42, 90, 81, 62, 90, 89, 35, 81, 48, 33, 94, 81, 76, 86, 67, 70, 100, 80, 83, 78, 96, 58

Note: m = 71.47 s = 20.98

Determine the maximum score, the minimum score, the range of scores (maximum – minimum) and a table with column headings:

Grade

Number of scores                             

using the following scoring (where m is the mean, s is the standard deviation, and x is an individual score):

A

:

m+ 4/3 s

<= x

A–

:

m+ 3/3 s

<= x <

m+ 4/3 s

B+

:

m+ 2/3 s

<= x <

m+ 3/3 s

B

:

m+ 1/3 s

<= x <

m+ 2/3 s

B–

:

m+ 0/3 s

<= x <

m+ 1/3 s

C+

:

m– 1/3 s

<= x <

m+ 0/3 s

C

:

m– 2/3 s

<= x <

m– 1/3 s

C–

:

m– 3/3 s

<= x <

m– 2/3 s

D+

:

m– 4/3 s

<= x <

m– 3/3 s

D

:

m– 5/3 s

<= x <

m– 4/3 s

F

:

x <

m– 5/3 s

Place the output in a file, in an orderly format, and inform the user of the name of the file before exiting.

In addition to the project source code you must also turn in a design. The design can be in pseudocode or UML. If in UML it can be handwritten and submitted as a .gif, .jpg, or .pdf image; if in pseudocode submit it in a .doc. Remember C++ code only.

100, 94, 59, 83, 57, 11, 92, 76, 37, 89, 74, 59, 65, 79, 49, 89, 89, 75, 64, 82, 15, 74, 82, 68, 92, 61, 33, 95, 91, 82, 89, 64, 43, 93, 86, 65, 72, 40, 42, 90, 81, 62, 90, 89, 35, 81, 48, 33, 94, 81, 76, 86, 67, 70, 100, 80, 83, 78, 96, 58

Note: m = 71.47 s = 20.98

Explanation / Answer

// C++ code
#include <iostream>
#include <string>
#include <fstream>
#include <stdlib.h>
#include <math.h>

using namespace std;

#define MAX 100

int main()
{
   char name[MAX];
   char output[MAX] = "output.txt";
   float scores[200],sum = 0,mean,deviation;
   int count = 0,i;
   string content;

   cout<<"Enter the name of file:: ";
   cin>>name;

   ifstream infile;
   ofstream outfile;
   infile.open(name);
   outfile.open(output);

   while(infile>>content)
       scores[count++] = atoi(content.c_str());

   infile.close();

   int max = scores[0];
   int min = scores[0];
   for(i=0;i<count;i++)
   {
      sum += scores[i];
      if(scores[i] < min)
        min = scores[i];
      if(scores[i] > max)
        max = scores[i];
   }

   mean = sum/count;
   outfile<<"minimum score is " << min << endl;
   outfile<<"maximum score is " << max << endl;
   outfile<<"the range of scores is " << (max-min) << endl;
   outfile<<"The mean is "<<mean<<endl;
   sum = 0;

   for(i=0;i<count;i++)
       sum += (scores[i] - mean)*(scores[i] - mean);

   sum = sum/count;
   deviation = sqrt(sum);
   outfile<<"The standard deviation is "<<deviation<<endl;

   float m,s,x;
   m = mean;
   s = deviation;

   int A=0,Am=0,Bp=0,B=0,Bm=0,Cp=0,C=0,Cm=0,D=0,F=0;

   for(i=0;i<count;i++)
   {
       x = scores[i];
       if( x>= m+4/3.0*s )
           A++;
       else if( x>= m+3/3.0*s )
           Am++;
       else if( x>= m+2/3.0*s )
           Bp++;
       else if( x>= m+1/3.0*s )
           B++;
       else if( x>= m+0/3.0*s )
           Bm++;
       else if( x>= m-1/3.0*s )
           Cp++;
       else if( x>= m-2/3.0*s )
           C++;
       else if( x>= m-3/3.0*s )
           Cm++;
       else if( x>= m-4/3.0*s )
           D++;
       else
           F++;
   }

   outfile<<"Number of grades in category A = "<<A<<endl;
   outfile<<"Number of grades in category A- = "<<Am<<endl;
   outfile<<"Number of grades in category B+ = "<<Bp<<endl;
   outfile<<"Number of grades in category B = "<<B<<endl;
   outfile<<"Number of grades in category B- = "<<Bm<<endl;
   outfile<<"Number of grades in category C+ = "<<Cp<<endl;
   outfile<<"Number of grades in category C = "<<C<<endl;
   outfile<<"Number of grades in category C- = "<<Cm<<endl;
   outfile<<"Number of grades in category D = "<<D<<endl;
   outfile<<"Number of grades in category F = "<<F<<endl;

   cout<<"All results are stored in "<<output<<endl;
   return 1;
}


/*
input.txt
100
94
59
83
57
11
92
76
37
89
74
59
65
79
49
89
89
75
64
82
15
74
82
68
92
61
33
95
91
82
89
64
43
93
86
65
72
40
42
90
81
62
90
89
35
81
48
33
94
81
76
86
67
70
100
80
83
78
96
58

output.txt
minimum score is 11
maximum score is 100
the range of scores is 89
The mean is 71.4667
The standard deviation is 20.9845
Number of grades in category A = 2
Number of grades in category A- = 5
Number of grades in category B+ = 12
Number of grades in category B = 10
Number of grades in category B- = 7
Number of grades in category C+ = 5
Number of grades in category C = 7
Number of grades in category C- = 1
Number of grades in category D = 2
Number of grades in category F = 9
*/