Answered You can hire a professional tutor to get the answer.
I have to complete this program so that it assigns and prints letter grades by ranges (in addition to the percentage): A 90-100 B 80-89.99 C 70-79.99...
I have to complete this program so that it assigns and prints letter grades by ranges (in addition to the percentage): A 90-100B 80-89.99C 70-79.99D 60-69.99F < 60Also how many students fall into each category.---------------------------------------------------------------// Median Grades Calculation// #include <string>#include <vector>#include <algorithm>#include <iostream>#include <iomanip>#include <stdexcept>// using directivesusing std::vector;using std::cout;using std::streamsize;using std::endl;using std::max;using std::domain_error;///////////////////////////////////////////////////////////////////////////////// hold all information related to a single studentstruct student_info{// students name// midterm and final exam gradesvector<double> homework; // all homework grades};///////////////////////////////////////////////////////////////////////////////// compute the median of a vector<double>// note: calling this function copies the whole vectordouble median(vector<double> vec){typedef vector<double>::size_type vec_sz;vec_sz size = vec.size();if (size == 0)throw domain_error("vector is empty, median undefined");sort(vec.begin(), vec.end());vec_sz mid = size / 2;return size % 2 == 0 ? (vec[mid] + vec[mid-1]) / 2 : vec[mid];}///////////////////////////////////////////////////////////////////////////////// compute a student's overall grade from midterm and final exam // grades and homework gradedouble grade(double midterm, double final, double homework){return 0.2 * midterm + 0.4 * final + 0.4 * homework;}// Compute a student's overall grade from midterm and// final exam grades and all homework grades.// This function does not copy the vector argument // (as median does so for us).double grade(double midterm, double final, vector<double> const& hw){if (hw.size() == 0)throw domain_error("student has done no homework");return grade(midterm, final, median(hw));}// Calculate the final grade for one studentdouble grade(student_info const& s){return grade(s.midterm, s.final, s.homework);}///////////////////////////////////////////////////////////////////////////////// read homework grades from an input stream// into a vector<double>istream& read_hw(istream& in, vector<double>& hw){if (in) {// get rid of previous contents// read homework gradesdouble x;while (cin >> x) hw.push_back(x);// clear the stream so that input will work for// the next studentin.clear();}return in;}// read all information related to one studentistream& read(istream& in, student_info& s){// read the students name, midterm and final exam gradesin >> s.name >> s.midterm >> s.final;// read all homework grades for this studentreturn read_hw(in, s.homework);}///////////////////////////////////////////////////////////////////////////////// compare two student_info instances, return whether 'x'// is smaller than 'y' based on comparing the stored names// of the studentsbool compare(student_info const& x, student_info const& y){return x.name < y.name;}///////////////////////////////////////////////////////////////////////////////int main(){// all student records// length of longest name // read and store all the records, find the length of // the longest namestudent_info record;while (read(cin, record)) {maxlen = max(maxlen, record.name.size());students.push_back(record);}// alphabetize the recordssort(students.begin(), students.end(), compare);for (vector<student_info>::size_type i = 0; i != students.size(); ++i) {// write the name, padded on the right side to maxlen + 1 characterscout << students[i].name << string(maxlen + 1 - students[i].name.size(), ' '); // compute and write the gradetry {double final_grade = grade(students[i]);streamsize prec = cout.precision();cout << setprecision(3) << final_grade << setprecision(prec);} catch (domain_error e) {cout << e.what();}cout << endl;}return 0;}