Thank you include include using namespace std struct STUDENT


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 ;
}









Solution

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 ;

}

 Thank you #include<iostream> #include<limits> using namespace std; struct STUDENT_TYPE { string name; int ID; double GPA; string Major; // calculat
 Thank you #include<iostream> #include<limits> using namespace std; struct STUDENT_TYPE { string name; int ID; double GPA; string Major; // calculat
 Thank you #include<iostream> #include<limits> using namespace std; struct STUDENT_TYPE { string name; int ID; double GPA; string Major; // calculat
 Thank you #include<iostream> #include<limits> using namespace std; struct STUDENT_TYPE { string name; int ID; double GPA; string Major; // calculat

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site