(Solved) : Write C Program Reads Data Input File Takes Data Computes Student Grades Assignment Conver Q42695524 . . .

Write a C++ program that reads data from an input file, takesthe data and computes student grades for an assignment byconverting the raw score to a percentage given each student’s scoreand the total points. The final score must be rounded up to thenearest whole value using the ceil function in the <cmath>header file and displayed as a percentage. You must also displaythe floating-point result up to 5 decimal places.

You must use at least 2 functions: one to print the last name ofthe student and another function to compute and print thepercentage as well as “Excellent” if the grade is greater than 90,”Well Done” if the grade is greater than 80, “Good” if the grade isgreater than 70, “Need Improvement” if the grade is greater than orequal to 60, and “Fail” if the grade is less than 50. The mainfunction is responsible for reading the input file and passing theappropriate arguments to your functions.

Here is an example of what the input file might look like:

Here is the code i written, i keep getting errors

//Include statements
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <cmath>
using namespace std;

//Global declarations: Constants and type definitions only — novariables
string infile;
string lastName;
int score;
double total;
double grade;
string description;

//Function prototypes

int main()
   //In cout statement below SUBSTITUTE your name and labnumber
   cout << “Herbert Reedus — Lab Number 5″<< endl << endl;

   //Variable declarations
   ifstream infile;

   //Program logic
   infile >> lastName;
   while (infile)
       infile >> score;
       infile >> total;

       // determining the grade out of100
       grade = score / total * 100;

       // The grades description basedupon the above result
       if (grade > 90)
           description =”Excellent”;
       else if (grade > 80)
           description =”Well Done”;
       else if (grade > 70)
           description =”Good”;
       else if (grade >= 60)
           description =”Need Improvement”;
           description =”Fail”;
       cout << lastName << “”<< setprecision(10) << fixed << round(grade)<< “% ” << setprecision(4) << fixed <<(grade * 0.01) << ” ” << description <<endl;;

       infile >> lastName;

   //Closing program statements

   return 0;

This is my text file
lastname Williams score 45 total 60
Lastname Robins score 53 total 60
LastName Richards score 39 total 60
Lastname Greedy Score 45 Total 60
LastName Gallows score 55 total 60
Lastname Denni Score 51 total 60

Expert Answer

Answer to Write a C++ program that reads data from an input file, takes the data and computes student grades for an assignment by …

Leave a Comment


We are the best freelance writing portal. Looking for online writing, editing or proofreading jobs? We have plenty of writing assignments to handle.

Quick Links

Browse Solutions

Place Order

About Us

× How can I help you?