Help With Grading Program

I have this base program that I created and need to add in a sorter, apply letter grades to the sorted scores, put everything into function format, and output everything to a .doc file. I would greatly appreciate help with this. Thank you.

Also, It does not look formatted properly when providing the code. Sorry about that.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
// =============================================================================
//   Input Required: The input required is the grades from the user when
//                   they are prompted. File containing input has been made for
//                   convenience.
//   Output Desired: The output desired is the User Grades.doc, where all of the
//                   grades will be recorded.
// =============================================================================

#include <conio.h>
#include <fstream.h>
#include <iomanip>
#include <iostream>
#include <stdlib.h>
#include <math.h>

ofstream fout; // This is the output textfile.

using namespace std;

// =============================================================================

int main ()
  {
    // Variable Declaration

    double a [100];
    int ScoreReplace;
    int i;
    int count;
    const int sentinel = -1;
    char reply;
    double sum, sumsqr, average, stddev;

    /* 
    ============================================================================
     Alphabetized Variable Dictionary

          average: This will show the average of all of the scores entered by 
                   the user.
                   It uses the sum and count variables to calculate this.
        a [count]: This is a placeholder for each score that is input by the 
                   user.
            count: This is used to record the number of inputs from the user
             fout: output textfile
            reply: This is used to determine whether the input by the user is 
                   correct.
                   It forces the user to answer Y, y, N, or n. If the user 
                   enters an invalid response, the process will not continue.
     ScoreReplace: This is the variable that will be used when a user is 
                   replacing a score within the array.
         sentinel: This is the number used to end the data stream when the input
                   is equal to it.
           stddev: This is the variable for standard deviation from the average 
                   of the scores. It uses the sum and sumsqr variables.
              sum: This is used to combine all scores for the average 
                   calculation
           sumsqr: This variable is used within the stddev, or Standard 
                   Deviation, calculations.          
    ============================================================================
    */
       
    fout.open ("User Grades.doc");

    cout << endl << endl << endl << endl << endl << endl << endl << endl;
    cout << setw (64) << "GGGG   RRRRR    AAAA   DDDDD   EEEEEE  RRRRR  ";
    cout << endl;
    cout << setw (63) << "GG  GG  RR  RR  AA  AA  DD  DD  EE      RR  RR";
    cout << endl;
    cout << setw (63) << "GG  GG  RR  RR  AA  AA  DD  DD  EE      RR  RR";
    cout << endl;
    cout << setw (63) << "GG      RRRRR   AAAAAA  DD  DD  EEEEEE  RRRRR ";
    cout << endl;
    cout << setw (63) << "GG      RRRR    AAAAAA  DD  DD  EEEEEE  RRRR  ";
    cout << endl;
    cout << setw (63) << "GG GGG  RRRRR   AA  AA  DD  DD  EE      RRRRR ";
    cout << endl;
    cout << setw (63) << "GG  GG  RR  RR  AA  AA  DD  DD  EE      RR  RR";
    cout << endl;
    cout << setw (63) << "GGGGGG  RR  RR  AA  AA  DDDDDD  EEEEEE  RR  RR";
    cout << endl;
    cout << endl << endl << endl;
    cout << setw (53) << "Press Enter to Continue...";
    cin.get ();
    system ("cls");  // This is used to open a new console window.

    do // This is to be used when there is a set, or another set of grades.
  	  {
		count = 0;

		do // This is to prompt the user for a set of grades.
	      {
			count ++;
			cout << endl << endl;
			cout << setw (40) << "Please enter the user's scores. ";
			cout << setw (5) << "Entering -1 will end score input." << endl;
			cout << endl;
			cout << setw (50) << "Enter score number " << count << ": ";
			cin >> a [count];
		  }
		while ( a [count] != -1);

        count --;
		// echo print scores

		do
		  {
			system ("cls");

			for ( i = 1; i <= count; i++)
			  {
				if (( i - 1) % 6 == 0)
				  {
					cout << endl << endl;
				  }

				cout << setw (5) << "[";
				cout << setw (2) << i << "]";
				cout << setw (4) << a [i];

              }

			cout << endl << endl << endl;
			cout << setw (40) << "Enter the index you ";
            cout << "would like to correct." << endl;
            cout << setw (50) << "Enter 0 to continue.";
			cout << endl;
			cout << setw (46) << "Enter index: ";
			cin >> ScoreReplace;

			if (ScoreReplace != 0)
			  {
				cout << setw (46) << "Enter replacement grade";
                cout << " for score #" << ScoreReplace << ": ";
			    cin >> a [ScoreReplace];
			  }

			cin.get ();
		  }
		while (ScoreReplace != 0);
                
		for (i = 1; i <= count; i++)
		  {
            if (( i - 1) % 25 == 0)
              {
                if ((i - 1) != 0)
			      {
				    fout << "\f";
			      }
			  
		        fout << setw (45) << "User Grades" << endl << endl;
              }

            fout << setw (35) << "[";
            fout << setw (2) << i << "]";
            fout << setw (4) << a [i];	
            fout << endl << endl;					
          }
                
        system ("cls");
        cout << setw (55) << "These are the finalized scores.";

		for (i = 1; i <= count; i++)
		  { 
			if (( i - 1) % 6 == 0)
 			  {
				cout << endl << endl;
			  }

            cout << setw (5) << "[";
            cout << setw (2) << i << "]";
            cout << setw (4) << a [i];						
		  }
					
        cout << endl << endl;
        cout << setw (50) << "Please press enter.";
        cin.get();
                
        sum = 0.0;
        sumsqr = 0.0;

        for ( i = 1; i <= count; i++)
		  {
		    sum = sum + a [i];
		    sumsqr = sumsqr + (a [i] * a [i] );
          }   

        average = sum / count;
        stddev = sqrt ((count * sumsqr - (sum * sum) ) / (count * (count - 1)));

	    system ("cls");         
        cout << endl << endl << endl << endl << endl << endl << endl << endl;
	    cout << setw (40) << "The average of this ";
        cout << "set of scores is: " << setprecision (4) << average;
	    cout << endl << endl << endl;
	    cout << setw (40) << "The standard deviation ";
        cout << "of the scores is: " << setprecision (4) << stddev;
	    cout << endl << endl << endl;
        cout << setw (51) << "Press Enter to close.";
	    cin.get ();

        do // This is to prompt another set of grades to be entered by the user.
		  {
	  	    system ("cls");
	  	    cout << endl << endl << endl << endl << endl << endl << endl << endl;
            cout << setw (56) << "Is there another set of grades?" << endl << endl;
            cout << setw (49) << "y = yes or n = no: ";
	  	    cin >> reply;
	  	  }
        while ((reply != 'n') && (reply != 'N') &&
               (reply != 'y') && (reply != 'Y'));
 	  }
	while ((reply != 'N') && (reply != 'n'));

    fout.close();

    return 0;
 }

// ============================================================================= 
Last edited on
I really need help with this if anyone could be of assistance. Thank you
and output everything to a .doc file.

Text file, you mean. You can't produce Word documents without extra libraries or without understanding the file format.

add in a sorter

Sorting is done with std::sort.
Topic archived. No new replies allowed.