Is this program correct and fully functional?

can you check for any errors?

#include<iostream>
#include<iomanip>
using namespace std;
int main ( )

{
double grade1, grade2, grade3, grade4, grade5;
double avg;
int students;
char lettergrade;
cout<<"How many students there are to be processed?n";
cin>>students;
for(int i=1; i<=students; i++) {

cout<<"grade1 = n";
cin>>grade1;
cout<<"grade2= n";
cin>>grade2;
cout<<"grade3= n";
cin>>grade3;
cout<<"grade4= n";
cin>>grade4;
cout<<"grade5= n";
cin>>grade5;
cout<<"Grade1tGrade2tGrade3tGrade4tGrade5t"<<endl;
cout<<grade1<<"t"<<grade2<<"t"<<grade3<<"t"<<grade4<<"t"<<grade5<<endl;

grade1=grade1 *.20;
grade2 = grade2*.20;
grade3 = grade3*.20;
grade4 = grade4 *.10;
grade5 = grade5*.30;
avg= (grade1+grade2+grade3+grade4+grade5);
if (avg >= 90.0 && avg<= 100.0)
lettergrade= 'A' ;
else if(avg >= 80.0 && avg<= 89.9)
lettergrade='B';
else if (avg>= 70.0 && avg<= 79.9)
lettergrade='C';
else if (avg>= 60.0 && avg<= 69.9)
lettergrade='D';
cout<<setprecision(2)<< fixed;
cout<<avg<<"t"<<lettergrade<<endl;

}

cin.get();;
return 0;

}
Fisrt use code tags please :)
Then what is that "t" ? Did you mean '\t' ?
Last have you learn aabout array ? In the way you did it, is you're just overwrite almost everytng instead of saving it
Oh i am new to this programming so that would explain why. My professor wants us to write a program which is due tomorrow.
Have you learn about array ? If you haven't then your code is fine :o
In cout<<grade1<<"t"<<grade2 what are you trying to do with "t" ?
Last edited on
Topic archived. No new replies allowed.