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

Need C++ Code for this project below CPP- Project Number 5 (After Chapter 7 ) A

ID: 3717228 • Letter: N

Question

Need C++ Code for this project below

CPP- Project Number 5 (After Chapter 7 )

A teacher has 20 students who have taken 4 tests. The teacher uses the following grading system to assign a letter grade to a student, based on the average of his or her four test scored:

                Test Score                                                Letter Grade

                90 – 100                                                               A

                80 -   89                                                                B

                70 – 79                                                                  C

                60 – 69                                                                  D

                0 – 59                                                                   F

Write a program class that uses a String array object to hold the 20 students’ names, an array containing 20 groups of four doubles to hold each students’ set of test scores. The program class should have methods that return a specific students’ name, the average test score and a letter grade based on the array.

Demonstrate the class in a program that allows the user to enter each student’s name and his or her four test scores. It should then display each student’s average test score and letter grade. In addition create an average score over the entire class for each test and an average over all for all tests for all students and display these values

Input can be typed in via the keyboard or entered through a data file containing the information on the next page.

Input validation:   Do not accept test scores less than zero or greater than 100.

Data for CPP Project Number Five

                Student                                Score 1                  Score 2                  Score 3                  Score 4

Angela Amon                     70.0                        80.0                        90.0                    100.0

Bruno Bwana                     82.0                        92.0                        72.0                       90.0

Charles Cary                       63.0                        73.0                        79.0                       85.0

Dennis Donley                   52.0                        65.0                        80.0                    89.0

Edgar Eastwood                 65.0                        70.0                        85.0                     91.0

Frances Forlon                   75.0                        79.0                        86.0                     95.0

George Gormley              66.0                        80.0                        87.0                     96.0

Harvey Heath                     67.0                        81.0                        88.0                     97.0

Isabel Iona                       97.0                        95.0                        85.0                     90.0

Jason Jasper                       99.0                        95.0                       85.0                     100.0

Kate Klawson                     90.0                        92.0                          94.0                    96.0

Larry Longfellow              89.0                        93.0                          95.0                    99.0

Mary Moore                      42.0                        72.0                          76.0                    79.0

Nancy Nusbaum              54.0                        64.0                          74.0                    80.0

Oscar Omega                     72.0                        76.0                       90.0                     95.0

Paul Penguin                      76.0                        80.0                       87.0                     92.0

Quincy Qualuda               85.0                        90.0                       90.0                     98.0

Roberta Ross                    86.0                        92.0                       96.0                     100.0

Sally Sucrose                    71.0                        81.0                       85.0                        84.0

Theresa Talbot                35.0                       63.0                       85.0                        89.0

Explanation / Answer

Code:

#include <iostream>

using namespace std;
class Student{
private:
int a,b,c,d; //four test scores
float avg;
char grade;
string name;
public:
void setData(string name,int a,int b,int c,int d){
this->a = a;
this->b=b;
this->c=c;
this->d=d;
this->name=name;
}
float getAvg(){
avg = (a+b+c+d)/4;
return avg;
}
char getGrade(){
if(avg>=90)
grade='A';
else if(avg>=80)
grade='B';
else if(grade>=70)
grade='C';
else if(grade>=60)
grade='D';
else
grade='F';
return grade;
}
string getName(){
return name;
}
int getScore1(){
return a;
}
int getScore2(){
return b;
}
int getScore3(){
return c;
}
int getScore4(){
return d;
}
  
};
int valid(int val){ //function to validate input score
if(val>=0 && val<=100){
return 1;
}
else
return 0;
};
int main()
{
int t;
cout<<"enter number of students: ";
cin>>t;
  
Student s[t];

//taking input
for(int i=0;i<t;i++){
string name;
int a,b,c,d;
cout<< "Enter name and marks of student no "<<i+1<<" : "<<endl;
cin>>name>>a>>b>>c>>d;
if(valid(a)==1 && valid(b)==1 && valid(c)==1 && valid(d)==1){
s[i].setData(name,a,b,c,d);
}
}
int tot1,tot2,tot3,tot4;
tot1=tot2=tot3=tot4=0; //int to store total score of student in each of 4 subjects
cout<<"Student Average Grade"<<endl;
for(int i=0;i<t;i++){
cout<<s[i].getName()<<" "<<s[i].getAvg()<<" "<<s[i].getGrade()<<endl;
tot1+=s[i].getScore1();
tot2+=s[i].getScore2();
tot3+=s[i].getScore3();
tot4+=s[i].getScore4();
}
float avg1 = tot1/20;
float avg2 = tot2/20;
float avg3 = tot3/20;
float avg4 = tot4/20;
cout<<"Average of all student in 4 subjects are: "<<avg1<<" "<<avg2<<" "<<avg3<<" "<<avg4<<endl;

return 0;
}

Sample Output:

Enter name and marks of student no 1 : abc 70 80 99 45

Enter name and marks of student no 2 : deg 87 98 56 67

Enter name and marks of student no 3 : eaffea 78 89 87 89

Enter name and marks of student no 4 : vca 77 88 66 99

Student Average Grade

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