I have finished it, but to don't violate the rules of this website --"Don't give away code" , I can not give you all my source code. The following is the framework of program. hope it can help you.
#include <iostream>
#include <vector>
using namespace std;
struct Student
{
string name;
float grade;
};
char convert(float grade)
{
if (grade >= 90)
return 'A';
if ( grade >= 80)
return 'B';
.......
}
void sortStudents(vector<Student>& students)
{
}
float getAverage(const vector<Student>& students)
{
int size = students.size();
float total = 0.0;
for (int i=0; i<size; ++i)
{
...............
}
return total / size;
}
void display(const vector<Student>& students)
{
cout<<"===================="<<endl;
cout<<"CLASS GRADE REPORT :"<<endl;
cout<<"____________________"<<endl;
int size = students.size();
for (int i=0; i<size; ++i)
{
cout<<students[i].name<<"\t"<<convert(students[i].grade)<<endl;
}
cout<<"_____________________"<<endl;
cout<<"HIGHEST GRADE : "<<students[0].grade<<endl;
cout<<"LOWEST GRADE : "<<students[students.size() -1].grade<<endl;
cout<<"AVERAGE : "<<getAverage(students)<<endl;
cout<<"====================="<<endl;
}
int main()
{
int number;
vector<Student> students;
cout<<"How many students do you want to process?"<<endl;
cin>>number;
for (int i=0; i<number; ++i)
{
Student temp;
//deal with the input and then construct the struct 'temp'
students.push_back(temp);
}
sortStudents(students);
display(students);
system("PAUSE");
return 0;
}