Grading program for an unknown number of students with several qualifiers.

Hello everyone!

I was wondering if you guys could give me a hand. This is my final assignment for my introductory C++ course and I am a little confused about where to go from here. We are suppose to use our 2nd assignment as a "launching off" point for this new one, but there are so many new requirements that I am confused as to how to start. Here is the assignment:

Write a C++ program that accepts three grades (whole numbers) from the keyboard for any number of students, with the maximum number of students that can be entered is 30 students. For each student, it calculates the average of the three grades and the equivalent letter grade. After reading the grades, processing the average and the letter grade, it prints out the student number, the three grades, the average, and the equivalent letter grade to the screen. You program should define a function-template the will be used for a function to calculate the average grade for three grades (10 points). Your program should also use two functions, one to find the highest average-grade in class and another function to find the least average-grade in class (10 points). In addition, your program will calculate the class average (the average of averages) and prints the result to the screen (10 points). Make sure to document your program and functions by adding multi-lines comment that describe what each function is doing. Do not forget to include your name at the top of the program (10 points). You should utilize one-dimensional arrays data structure for your variables (10 points).


Here's the code with which I am working:

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
#include <iostream> 

#include <iomanip> 

using namespace std; 

char LetterGrade(double); 

double Average(int, int, int); 

int main() 

{ 

 int grade1, grade2, grade3; 

 int numberofStudents; 

 double totalofAver = 0; 

 double studentaver; 

 cout << "Enter the number of students in class: "; 

 cin >> numberofStudents; 

 cout << setprecision(2) << fixed; 

 for (int i = 0; i < numberofStudents; i++) 

 { 

 cout << "\nEnter three grade for student number " << i + 1 << " : "; 

 cin >> grade1 >> grade2 >> grade3; 

 cout << "\nStudent number " << i + 1 << " grades " << grade1 << " " << grade2 << " " << grade3; 

 studentaver = Average(grade1, grade2, grade3); 

 cout << " average of the grades " << studentaver << " letter grade: "; 

 cout << LetterGrade(studentaver); 

 totalofAver += studentaver; 

 } 

 cout << "\nThe class average " << totalofAver / numberofStudents; 

} // end main 

double Average(int g1, int g2, int g3) 

{ 

 return (g1 + g2 + g3) / 3.0; 

} 

char LetterGrade(double avgrade) 

{ 

 char letter; 

 if (avgrade >= 90 && avgrade <= 100) 

 letter = 'A'; 

 else if (avgrade >= 80 && avgrade < 90) 

 letter = 'B'; 

 else if (avgrade >= 70 && avgrade < 80) 

 letter = 'C'; 

 else if (avgrade >= 60 && avgrade < 70) 

 letter = 'D'; 

 else if (avgrade >= 0 && avgrade < 60) 

 letter = 'F'; 

 else 

 letter = 'U'; 

 return letter; 

}


How do you guys suggest I begin? Can anyone give me a little guidance. Thanks, in advance!
Last edited on
please use code tags.
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
#include <iostream> 

#include <iomanip> 

using namespace std; 

char LetterGrade(double); 

double Average(int, int, int); 

int main() 

{ 

int grade1, grade2, grade3; 

int numberofStudents; 

double totalofAver = 0; 

double studentaver; 

cout << "Enter the number of students in class: "; 

cin >> numberofStudents; 

cout << setprecision(2) << fixed; 

for (int i = 0; i < numberofStudents; i++) 

{ 

cout << "\nEnter three grade for student number " << i + 1 << " : "; 

cin >> grade1 >> grade2 >> grade3; 

cout << "\nStudent number " << i + 1 << " grades " << grade1 << " " << grade2 << " " << grade3; 

studentaver = Average(grade1, grade2, grade3); 

cout << " average of the grades " << studentaver << " letter grade: "; 

cout << LetterGrade(studentaver); 

totalofAver += studentaver; 

} 

cout << "\nThe class average " << totalofAver / numberofStudents; 

} // end main 

double Average(int g1, int g2, int g3) 

{ 

return (g1 + g2 + g3) / 3.0; 

} 

char LetterGrade(double avgrade) 

{ 

char letter; 

if (avgrade >= 90 && avgrade <= 100) 

letter = 'A'; 

else if (avgrade >= 80 && avgrade < 90) 

letter = 'B'; 

else if (avgrade >= 70 && avgrade < 80) 

letter = 'C'; 

else if (avgrade >= 60 && avgrade < 70) 

letter = 'D'; 

else if (avgrade >= 0 && avgrade < 60) 

letter = 'F'; 

else 

letter = 'U'; 

return letter; 

}
I'm sorry, I updated it. I'm brand new to this forum. My bad. :(
Last edited on
You are on the right path.
Just to add.

1
2
3
4
5
6
7
8
9
10
-get number of students
-for every student
    -get three grades
    -print student number
    -compute average of the 3 grades and print
    -compute letter grade and print
    -class average += student average
    -get min and max average
-class avergae /= number of stuents
}


There is no implementation of arrays anywhere here. But then,
You should utilize one-dimensional arrays data structure for your variables

In that case, you'll surely need a struct . Are you ok using structures/records?
Last edited on
Thank you so much... For some reason it looks much simpler in pseudocode. :)
Topic archived. No new replies allowed.