Answer to Question #287222 in C++ for Muzammil

Question #287222

write a program in c++ that inputs semester wise grades of a student along with subjects and print the transcript of awards of student


1
Expert's answer
2022-01-13T03:56:41-0500
#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;
	}
	
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment