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

C++ Professor Zak has asked you to create a grading program for her Physics clas

ID: 3920540 • Letter: C

Question

C++

Professor Zak has asked you to create a grading program for her Physics class. She administers a variable number of 100-point quizzes during the semester. Unfortunately, the number of quizzes varies from semester to semester (sometimes significantly). All students take the same number of quizzes during the semester however. Design and code an application that accepts a student name and the quiz scores. Output the student’s name, all test scores (and letter grades) and the GPA. Then output the corresponding letter grade and words of advice.

// Specification C1 - Student Summary
Display the number of tests, the score for each test and the average
grade for the class for each student.
2. // Specification C2 - Student Name
Allow name to accept first plus last name (ie 2 words).
3. // Specification C3 - Grade Input Validation
Range test the input data for the grades (0 to 100 points possible).
4. // Specification C4 - GPA Advice
Provide a letter grade and comment on how the student is doing.

1. // Specification B1 - Pseudo Dynamic Array
Prompt Professor Zak for the number of quizzes at the start of the
program and then create the appropriately sized array.
2. //Specification B2 - Drop Lowest
Professor Zak will drop the lowest 3 test scores from the GPA
calculation, but only if there are 4 tests or more.
3. // Specification B3 - Signify Dropped
Include the dropped tests when printing out all the test scores
for the student, but signify if the test was dropped by displaying
"DROPPED" next to the score.
4. // Specification B4 – Sorted Output

Sort the output scores from highest to lowest score. Put this speci-
fication comment right above your sorting code.

1. // Specification A1 - Main Student Loop
Up to this point, you can code this so you need to rerun it for each
student. Now, expand the program and allow Professor Zak to
enter the number of students in her class. She will then enter all
the data during one program run. Generate the outputs as earlier
for each student.
2. // Specification A2 - Number of Students Prompt
Ask Professor Zak to enter the number of students in her class.
This will drive the main student loop.
3. // Specification A3 - Class Stats
Compute the overall score for the class for each test.

Explanation / Answer

Here is the completed code for this problem. Comments are included, go through it, learn how things work and let me know if you have any doubts. Thanks

//Code

#include<iostream>

using namespace std;

//method to get score from the user, return it after proper validation

double getScore(int quizNum){

              cout<<"Enter score for quiz "<<quizNum<<": ";

              double score;

              cin>>score;

              // Specification C3

              if(score>=0 && score<=100){

                             return score;

              }else{

                             //invalid, asking again

                             cout<<"ERROR: Score should be between 0 and 100, try again!"<<endl;

                             return getScore(quizNum);

              }

}

//method to sort the quiz scores in descending order

//Specification B4

void sortScores(double *scores,int count){

              for(int i=0;i<count;i++){

                             for(int j=0;j<count-1;j++){

                                           if(scores[j]<scores[j+1]){

                                                          double temp=scores[j];

                                                          scores[j]=scores[j+1];

                                                          scores[j+1]=temp;

                                           }

                             }

              }

}

//method to find the average score counting 'count' number of scores

double averageScore(double *scores,int count){

              double sum=0;

              //finding sum

              for(int i=0;i<count;i++){

                             sum+=scores[i];

              }

              //finding average

              double avg=(double) sum/count;

              return avg;

}

//method to find the letter grade from average score

char letterGrade(double average){

              if(average>=90){

                             return 'A';

              }else if(average>=80){

                             return 'B';

              }else if(average>=70){

                             return 'C';

              }else if(average>=60){

                             return 'D';

              }else{

                             return 'F';

              }

}

//method to find the student remarks from GPA

// Specification C4

string getRemarks(char GPA){

              if(GPA=='A'){

                             return "Exceptional!";

              }else if(GPA=='B'){

                             return "Very Good!";

              }else if(GPA=='C'){

                             return "Good!";

              }else if(GPA=='D'){

                             return "Average!";

              }else{

                             return "Failed";

              }

}

//method to print all stats of a student

// Specification C1

void printStats(string name,double *scores, int numQuizzes){

             

              cout<<name<<endl;

              cout<<"Scores: "<<endl;

              for(int i=0;i<numQuizzes;i++){

                             cout<<scores[i]<<" ";

                             if(i>=numQuizzes-3){

                                           //Specification B3

                                           cout<<"(DROPPED) ";

                             }

              }

              cout<<endl;

              double avg;

              char GPA;

              if(numQuizzes>=4){

                             //dropping lowest 3 scores and finding the average

                             //Specification B2

                             avg=averageScore(scores,numQuizzes-3);

              }else{

                             avg=averageScore(scores,numQuizzes);

              }

             

              GPA=letterGrade(avg);

              string remarks=getRemarks(GPA);

              cout<<"GPA: "<<GPA<<" ("<<avg<<" %)"<<endl;

              cout<<"Remarks: "<<remarks<<endl;

             

}

//method to print stats of whole class

//Specification A3

void printClassStats(double* scores, int numQuizzes){

              cout<<"Class Stats: "<<endl;

              //printing total scores for each test

              for(int i=0;i<numQuizzes;i++){

                             cout<<"Total score for Quiz "<<(i+1)<<": "<<scores[i]<<endl;

              }

}

int main(){

             

              int num_students,num_quizzes;

              cout<<"Enter number of students: ";

              //Specification A2

              cin>>num_students;

              cout<<"Enter number of quizzes: ";

              cin>>num_quizzes;

              //defining two pseudo dynamic arrays to store quiz scores for a student

              // and total quiz scores for whole class

              // Specification B1

              double quiz_scores[num_quizzes];

              double class_scores[num_quizzes];

             

              for(int i=0;i<num_quizzes;i++){

                             //initializing class scores to 0

                             class_scores[i]=0;

              }

              //looping for given number of students

              //Specification A1

              for(int i=0;i<num_students;i++){

                             string firstName,lastName;

                             //getting first and last names

                             // Specification C2

                             cout<<"Enter student "<<(i+1)<<"'s first name: ";

                             cin>>firstName;

                             cout<<"Enter student "<<(i+1)<<"'s last name: ";

                             cin>>lastName;

                             //getting scores for each quiz

                             for(int j=0;j<num_quizzes;j++){

                                           double score=getScore(j+1);

                                           quiz_scores[j]=score;

                                           //adding to the class score for current quiz

                                           class_scores[j]+=score;

                             }

                             //sorting scores in descending order

                             sortScores(quiz_scores,num_quizzes);

                             //printing stats of the student

                             printStats(firstName+" "+lastName,quiz_scores,num_quizzes);

                            

              }

              //printing stats of the class

              printClassStats(class_scores,num_quizzes);

             

              return 0;

}

/*OUTPUT*/

Enter number of students: 2

Enter number of quizzes: 5

Enter student 1's first name: Oliver

Enter student 1's last name: Queen

Enter score for quiz 1: 98

Enter score for quiz 2: 78

Enter score for quiz 3: 66

Enter score for quiz 4: 999

ERROR: Score should be between 0 and 100, try again!

Enter score for quiz 4: 97

Enter score for quiz 5: 66

Oliver Queen

Scores:

98 97 78 (DROPPED) 66 (DROPPED) 66 (DROPPED)

GPA: A (97.5 %)

Remarks: Exceptional!

Enter student 2's first name: John

Enter student 2's last name: Diggle

Enter score for quiz 1: 80

Enter score for quiz 2: 70

Enter score for quiz 3: 60

Enter score for quiz 4: 50

Enter score for quiz 5: 40

John Diggle

Scores:

80 70 60 (DROPPED) 50 (DROPPED) 40 (DROPPED)

GPA: C (75 %)

Remarks: Good!

Class Stats:

Total score for Quiz 1: 178

Total score for Quiz 2: 148

Total score for Quiz 3: 126

Total score for Quiz 4: 147

Total score for Quiz 5: 106

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