I need help with formating a output for a grade report in c++. I need help with
ID: 3916558 • Letter: I
Question
I need help with formating a output for a grade report in c++. I need help with formating this to fit correctly, what I have looks like this:
Grade Summary
English Class
Student Name Final Exam Final Avg Letter Grade
-------------------------------------------------------------------------------------
Marvin Dipwart 72 79 D
Grade Summary
History Class
Student Name Final Exam Final Avg Letter Grade
-------------------------------------------------------------------------------------
Joe Schmuckatelli 98 88 D
Grade Summary
Math Class
Student Name Final Exam Final Avg Letter Grade
------------------------------------------------------------------------------------
Bugs
Bunny 93 87 D
Jimmy Crack Corn
here is some code
out << "Grade Summary" << endl;
out << "English Class ";
out << "Student Name" << " ";
out << "Final Exam ";
out << "Final Avg ";
out << "Letter Grade ";
out << "-------------------------------------------------------------------------------------" << endl << endl;
for (int i = 0; i < size; i++)
{
if (studentList[i]->GetCourse() == "English")
out << studentList[i]->GetFname() << " " << studentList[i]->GetLname() << " " << studentList[i]->Final() << " " << setprecision(2) << studentList[i]->Average() << " " << finalE << endl;
}
Explanation / Answer
// the only way is to add few " || " manually it will make it look better or use cout<<setw() this will help under header file <iomanip>
cout << "Grade Summary " << endl;
cout << "English Class ";
cout << "Student Name"<<setw(3)<< " ||";
cout << "Final Exam "<<setw(3)<<"||";
cout << "Final Avg "<<setw(3)<<" ||";
cout << "Letter Grade "<<setw(3) << " || ";
cout << "-------------------------------------------------------------------------------------" << endl << endl;
for (int i = 0; i < size; i++)
{
if (studentList[i]->GetCourse() == "English")
cout << studentList[i]->GetFname() <<setw(3)<< " || " << studentList[i]->GetLname() <<setw(3)<< " ||" << studentList[i]->Final()<<setw(3) << " || " << setprecision(2) << studentList[i]->Average()<<setw(3) << " || " << finalE << endl;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.