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

Thank you #include<iostream> #include<limits> using namespace std; struct STUDEN

ID: 3932861 • Letter: T

Question


Thank you

#include<iostream> #include<limits> using namespace std; struct STUDENT_TYPE { string name; int ID; double GPA; string Major; // calculating total amount of space: //name requires 8 characters=8*8=64 bytes //ID requires int=2 bytes //double requires double=4 bytes //Major requires 8 characters=8*8=64 bytes //total=134 bytes }; int main() { //create three student records STUDENT_TYPE student[3]; int best_student, i; double best_GPA; for(i=0;i<3;i++) { cout<<"Enter details for the student#"<<i+1<<endl; cout<<"Name:"; cin>>student[i].name; cout<<"ID : "; cin>>student[i].ID; cout<<"GPA :"; cin>> student[i]. GPA; cout<<"Major: "; cin>>student[i].Major; cout<<"_____________________________________________________________"<<endl; } //best student best_GPA=-1.0; best_student=-1; for( i=0;i<3;i++) { if(student[i].GPA>best_GPA) { best_GPA=student[i].GPA; best_student=i; } } if (best_student!=-1) cout<<"Best student is "<< student[best_student].name<<"with GPA= "<<best_GPA<< endl; else cout<<"Highest GPA isnot distinct.No single best student could be found."<<endl; //student with ID 101 for( i=0;i<3;i++ ) { if (student[i].ID==101) { cout<<"Student"<<student[i].name<<"has ID 101."<<endl; } } return 0 ; } #include<iostream> #include<limits> using namespace std; struct STUDENT_TYPE { string name; int ID; double GPA; string Major; // calculating total amount of space: //name requires 8 characters=8*8=64 bytes //ID requires int=2 bytes //double requires double=4 bytes //Major requires 8 characters=8*8=64 bytes //total=134 bytes }; int main() { //create three student records STUDENT_TYPE student[3]; int best_student, i; double best_GPA; for(i=0;i<3;i++) { cout<<"Enter details for the student#"<<i+1<<endl; cout<<"Name:"; cin>>student[i].name; cout<<"ID : "; cin>>student[i].ID; cout<<"GPA :"; cin>> student[i]. GPA; cout<<"Major: "; cin>>student[i].Major; cout<<"_____________________________________________________________"<<endl; } //best student best_GPA=-1.0; best_student=-1; for( i=0;i<3;i++) { if(student[i].GPA>best_GPA) { best_GPA=student[i].GPA; best_student=i; } } if (best_student!=-1) cout<<"Best student is "<< student[best_student].name<<"with GPA= "<<best_GPA<< endl; else cout<<"Highest GPA isnot distinct.No single best student could be found."<<endl; //student with ID 101 for( i=0;i<3;i++ ) { if (student[i].ID==101) { cout<<"Student"<<student[i].name<<"has ID 101."<<endl; } } return 0 ; }








Explanation / Answer

int main()

{

//create three student records

STUDENT_TYPE student[3];

int best_student, i;

double best_GPA;

for(i=0;i<3;i++)

{

cout<<"Enter details for the student#"<<i+1<<endl;

cout<<"Name:";

cin>>student[i].name;

cout<<"ID : ";

cin>>student[i].ID;

cout<<"GPA :";

cin>> student[i]. GPA;

cout<<"Major: ";

cin>>student[i].Major;

cout<<"_____________________________________________________________"<<endl;

}

//best student

best_GPA=-1.0;

best_student=-1;

for( i=0;i<3;i++)

{

if(student[i].GPA>best_GPA)

{

best_GPA=student[i].GPA;

best_student=i;

}

}

if (best_student!=-1)

cout<<"Best student is "<< student[best_student].name<<"with GPA= "<<best_GPA<< endl;

else

cout<<"Highest GPA isnot distinct.No single best student could be found."<<endl;

//student with ID 101

for( i=0;i<3;i++ )

{

if (student[i].ID==101)

{

cout<<"Student"<<student[i].name<<"has ID 101."<<endl;

}

}

return 0 ;

}

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