void add_record()
{
cout<<"how many student would you like to enter?"<<endl;
cin>>num;
cin.ignore(80,'
');
for(j=0; j<num;j++)
{
cout<<"Please enter full name"<<endl;
cin.get(fname[j],30);
cin.ignore(80,'
');
cout<<"Please the student's id number"<<endl;
cin.get(id[j], 15);
cin.ignore(80, '
');
cout<<"Please enter 4 scores and press enter"<<endl;
for(i=0; i<4;i++)
{
cin>>scores[i];
cin.ignore(80, '
');
total[j]=total[j]+scores[i];}
total[j]=total[j]/4;
}
calculate();
}
void calculate()
{
if((total[j]>90)&&(total[j]<100))
{
letter[j]='A';
}
if((total[j]>80)&&(total[j]<89))
{
letter[j]='B';
}
if((total[j]>70)&&(total[j]<79))
{
letter[j]='C';
}
if((total[j]>60)&&(total[j]<69))
{
letter[j]='D';
}
if((total[j]>0)&&(total[j]<59))
{
letter[j]='F';
}
display_record();
}
void display_record()
{
cout<<endl;
cout<<"Student"<<setw(10)<<"id#"<<setw(15)<<"Average"<<setw(15)<<"Letter"<<endl;
cout<<"------------"<<setw(10)<<"-------------"<<setw(10)<<"--------------"<<setw(10)<<"--------------"<<endl;
for(j=0;j<num;j++)
{
cout<<fname[j]<<setw(10)<<id[j]<<setw(15)<<total[j]<<setw(10)<<letter[j]<<endl;
}
questions();
}
this is my gradebook program... hmm... it only prints out the average for the last number if I did multiple inputs of student's scores.... and it only prints out when the student have f.....so I don't know what to do...

New Topic/Question
Reply




MultiQuote






|