jessiej6 (1) I've been trying to create a grading system using arrays but i've been having issues when it outputs. it doesn't output all of the courses i entered and the corresponding grades. Here is what i have so far. I also have no idea how to add the grade letter as well. sigh #include <iostream> #include<iomanip> using namespace std; int numStudents2; int main() { cout <<"Welcome to Jessie's Academy Grade Calculator" <<endl; cout <<"Enter number of students: "; cin >> numStudents2; const int numStudents = numStudents2; string studentName[numStudents]; int numCourses[numStudents]; string courseName[numStudents]; double courseGrade[numStudents]; float aveGrade[numStudents]; double sumGrades[numStudents]; for (int i = 0; i<numStudents; i++) { cout << "Name of Student: "; cin >> studentName[i]; cout << "Number of courses taken: "; cin >> numCourses[i]; for (int j = 0; j < numCourses[i]; j++) { cout << "Name of course " << j+1 << " taken: "; cin >> courseName[j]; } for (int l = 0; l < numCourses[i]; l++) {cout << "Grade for course " << l+1 << ": "; cin >> courseGrade[l]; } sumGrades[i] += courseGrade[i]; aveGrade[i] = sumGrades[i] / numCourses[i]; } cout<<"\n\n********Grade Report*********" <<endl; cout <<"STUDENT NAME" <<"\t" <<"# OF COURSES" <<"\t" <<"COURSE NAME" <<"\t" <<"GRADE" <<"\t" <<"AVERAGE"<< endl; for (int k = 0; k<numStudents; k++) { cout << studentName[k]<< "\t\t"<< numCourses[k] << "\t\t" << courseName[k] << "\t\t" << courseGrade[k] << "\t\t" << "\n"; for (int m= 0; m<numStudents; m++) { cout<<"\t\t\t\t" <<courseName[m] << "\t\t" << courseGrade[m] << "\t\t" << aveGrade[m] << "\n"; } } double max = aveGrade[0]; double min = aveGrade[0]; for (int i = 0; i < numStudents; i++) { if (max < aveGrade[i]) max = aveGrade[i]; if(min > aveGrade[i]) min = aveGrade[i]; } cout<<"\n\nHighest Average: " << max; cout<<"\nLowest Average: " << min; return 0; } |
|
|
Welcome to Jessie's Academy Grade Calculator Enter number of students: 3 Name of Student 1: qwe Number of courses taken: 2 Name of course 1 taken: po Name of course 2 taken: lk Grade for course 1: 8 Grade for course 2: 9 Name of Student 2: asd Number of courses taken: 3 Name of course 1 taken: kj Name of course 2 taken: hg Name of course 3 taken: mn Grade for course 1: 6 Grade for course 2: 5 Grade for course 3: 4 Name of Student 3: zxc Number of courses taken: 2 Name of course 1 taken: hg Name of course 2 taken: bv Grade for course 1: 4 Grade for course 2: 5 ********Grade Report********* STUDENT NAME # OF COURSES AVERAGE COURSE NAME GRADE qwe 2 8.5 po 8 lk 9 asd 3 5 kj 6 hg 5 mn 4 zxc 2 4.5 hg 4 bv 5 Highest Average: 8.5 Lowest Average: 4.5 |