Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a C++ program that computes student grades for an assignment as a percenta

ID: 3754094 • Letter: W

Question

Write a C++ program that computes student grades for an assignment as a percentage given each student’s score and the total points. The final score should be rounded up to the nearest whole value using the ceil function in the <cmath> header file. You should also display the floating-point result up to 5 decimal places. The input to the program must come from a file containing multiple lines with the student’s last name, score, and total separated by a space. In addition, you should print to the console “Excellent” if the grade is greater than 90, “Well Done” if the grade is greater than 80, “Good” if the grade is greater than 70, “Need Improvement” if the grade is greater than or equal to 60, and “Fail” if the grade is less than 50. Here is an example of what the input file might look like:

Weems 50 60

Dale 51 60

Richards 57 60

Smith 36 60

Tomlin 44 60

Bird 45 60

The output of your program should look like this:

Weems 83% .83333 Well Done

Dale 85% .85000 Well Done

Richards 95% .95000 Excellent

Smith 60% .60000 Need Improvement

Tomlin 73% .73333 Good

Bird 75% .75000 Good

Explanation / Answer

#include<iostream>
#include<cmath>
#include<fstream>
#include<string>
#include<stdlib.h>
#include <iomanip>
using namespace std;
int main()
{
fstream file;
    string word,filename;
   
    int score,percent,total;
    float percent_f;
   

    filename = "input.txt";
    file.open(filename.c_str());

    while (file >> word)
    {
    cout << word << " ";
   
    score=0;
  percent=0;
    total=0;
    percent_f=0;
   
       
        file >> word;
        score=atoi(word.c_str());
       
       
        file >> word;
        total=atoi(word.c_str());
       
        percent=ceil((score*100)/total);
        percent_f=(score*100)/total;
        cout << percent <<"%.";
        cout << fixed;
        cout<<setprecision(5)<<percent_f<<" ";
       
        if(percent>90)
        {
        cout<<"Excellent";
  }
  else if(percent>80)
        {
        cout<<"Well Done";
  }
  else if(percent>70)
        {
        cout<<"Good";
  }
  else if(percent>=60)
        {
        cout<<"Need Improvement";
  }
  else
  {
   cout<<"Fail";
  }
        cout<<endl;
    }
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote