write a program in c++ that inputs semester wise grades of a student along with subjects and print the transcript of awards of student
#include<iostream>
#include<string>
#include<vector>
using namespace std;
struct Student
{
string sub;
double grade;
};
int main()
{
vector<Student*>v;
char choice;
do
{
cout<<"Do you want to enter a new grade for subject? [Y/N]: ";
cin>>choice;
if(choice=='N'||choice=='n')break;
Student* tmp=new Student;
cout<<"Please, enter a name of subject: ";
cin.ignore(256,'\n');
getline(cin,tmp->sub,'\n');
cout<<"Please, enter a grade for this subject: ";
cin>>tmp->grade;
v.push_back(tmp);
}while(true);
vector<Student*>::iterator it;
cout<<"Subject\t\t\tAward\n";
for(it=v.begin();it!=v.end();it++)
{
if((*it)->grade>=90)
cout<<(*it)->sub<<"\t\t"<<"A"<<endl;
else if((*it)->grade>=75&&(*it)->grade<90)
cout<<(*it)->sub<<"\t\t"<<"B"<<endl;
else if((*it)->grade>=60&&(*it)->grade<75)
cout<<(*it)->sub<<"\t\t"<<"C"<<endl;
else if((*it)->grade>=40&&(*it)->grade<60)
cout<<(*it)->sub<<"\t\t"<<"D"<<endl;
else
cout<<(*it)->sub<<"\t\t"<<"No award"<<endl;
}
}
Comments
Leave a comment