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

#include <iostream> #include <string.h> #include <stdlib.h> using namespace std;

ID: 663040 • Letter: #

Question

#include <iostream>
#include <string.h>
#include <stdlib.h>

using namespace std;

struct Student
{
string studFirstName,studLastName;
int studExam1,studExam2,studExam3; // 0 - 100
double studAvg;
char studGrade; //A-F
};

int main()
{
Student stud1;
char Grade;
for (int i = 0; i <3; i++)
{
//Input data
cout<<"Enter student's first and last name: ";
cin>>stud1.studFirstName >>stud1.studLastName;
cout<<"Enter three Exams: ";
cin>>stud1.studExam1 >>stud1.studExam2 >>stud1.studExam3;

//Process data
stud1.studAvg = (stud1.studExam1 + stud1.studExam2 + stud1.studExam3 ) /3;
if(stud1.studAvg >= 90)
Grade = 'A';
else if( stud1.studAvg >=80)
Grade = 'B';
else if (stud1.studAvg>=70)
Grade = 'C';
else if (stud1.studAvg >=60)
Grade = 'D';
else
Grade = 'F';
stud1.studGrade = Grade;
//Add the code to display the Student record for each student.
//MY CODE ADDED HERE

cout<<" "<<stud1.studFirstName<<" "<<stud1.studLastName;
cout<<" "<<stud1.studExam1<<" "<<stud1.studExam2<<" "<<stud1.studExam3;
cout<<" "<<stud1.studAvg<<" "<<stud1.studGrade;
}
system("pause");
return 0;
}

1) Create an array of Students with array size equal to three: (80 points)

Student studList[3];

Apply these set of data and display the Student record for each student.

jimmy shandeh

100 100 100

Mike Jackson

100 90 93

Mary Johnson

90 75 88

2) Add the logic and the code to find and display the highest studAvg. (20 points)

Explanation / Answer

#include <iostream>
#include <string>
using namespace std;

struct Student
{
string studFirstName,studLastName;

int studExam1,studExam2,studExam3; // 0 - 100

double studAvg;

char studGrade; // A-F
};

int main() {
  
Student stud1[3];
char Grade;
  
for (int i = 0; i <3; i++)
{
//Input data
cout<<"Enter student's first and last name: ";
cin >>stud1[i].studFirstName >>stud1[i].studLastName;
cout<<"Enter three Exams: ";
cin >>stud1[i].studExam1 >>stud1[i].studExam2 >>stud1[i].studExam3;
  
//Process data
stud1[i].studAvg = (stud1[i].studExam1 + stud1[i].studExam2 + stud1[i].studExam3 ) /3;

if (stud1[i].studAvg >= 90)
Grade = 'A';
else if( stud1[i].studAvg >=80)
Grade = 'B';
else if (stud1[i].studAvg>=70)
Grade = 'C';
else if (stud1[i].studAvg >=60)
Grade = 'D';
else
Grade = 'F';
  
stud1[i].studGrade = Grade;

cout<<"Name:"<<stud1[i].studFirstName<<stud1[i].studLastName<<" ";
cout<<"Marks in three subjects: "<<stud1[i].studExam1<<" "<<stud1[i].studExam2<<" "<<stud1[i].studExam3<<" ";
cout<<"Average:"<<stud1[i].studAvg<<" ";
cout<<"Grade:"<<Grade<<" ";
}
int highestAvge=stud1[0].studAvg,j=0;
for(j=0;j<3;j++){
if(highestAvge<stud1[j].studAvg){
highestAvge=stud1[j].studAvg;
}
}
cout<<"highest student average"<<highestAvge<<" ";
return 0;
}