Write a C++ program that computes a student’s grade for an assignment as a percentage given the student’s score and total points. The final score must be rounded up to the nearest whole value using the ceil function in the <cmath> header file. You must also display the floating-point result up to 5 decimal places. The input to the program must come from a file containing a single line with the score and total separated by a space. In addition, you must print to the console “Excellent” if the grade is greater than or equal to 90, “Well Done” if the grade is less than 90 and greater than or equal to 80, “Good” if the grade is less than 80 and greater than or equal to 70, “Need Improvement” if the grade is less than 70 and greater than or equal to 60, and “Fail” if the grade is less than 60.  If my input isWeems 83% .83333 Well DoneDale 85% .85000 Well Done Richards 95% .95000 Excellent Smith 60% .60000 Need Improvement Tomlin 73% .73333 Good Bird 75% .75000 Good

Question
Asked Nov 13, 2019
127 views

Write a C++ program that computes a student’s grade for an assignment as a percentage given the student’s score and total points. The final score must be rounded up to the nearest whole value using the ceil function in the <cmath> header file. You must also display the floating-point result up to 5 decimal places. The input to the program must come from a file containing a single line with the score and total separated by a space.

 

In addition, you must print to the console “Excellent” if the grade is greater than or equal to 90, “Well Done” if the grade is less than 90 and greater than or equal to 80, “Good” if the grade is less than 80 and greater than or equal to 70, “Need Improvement” if the grade is less than 70 and greater than or equal to 60, and “Fail” if the grade is less than 60.

 

 

If my input is

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

check_circle

Expert Answer

Step 1

Instructions for the given program:

  • For the given program, there should exist a file with the name “Report” in which student’s name, student’s score and total points should exist in the same order.
  • It prints the percentage of the student with whole value using the ceil function.
  • The floating point result will be displayed up to five decimal points.
  • Write message according to the grade.
Step 2

Program:

#include <iostream>

#include <cmath>

#include <fstream>

#include <iomanip>

using namespace std;

int main ()

{

     string Studentname;

     float StudentScore;

     float TotalPoints;

     ifstream myFile;

     //In my PC, file is saved with the name "input". If you use another file name, just change this line

     myFile.open ("Report.txt");

     if (myFile.is_open()) {

     //while there is data in the file

          while(myFile>>Studentname>>StudentScore>>TotalPoints)

          { 

          // print student name

              cout << Studentname<< " ";

              float GradePercentage = StudentScore/TotalPoints;

              int percent = ceil(GradePercentage*100);

              // print percentage

              cout<<percent<<"% ";

              cout<<fixed<<setprecision(5);

              ...

help_outline

Image Transcriptionclose

Report.txt- Notepad File Edit Format View Help Weems 30 60 Dale 45 60 Richards 55 60 Smith 40 60 Tomlin 50 60 Bird 35 60

fullscreen

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Science

Programing Language

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A
add
question_answer

Q: The area of an arbitrary triangle can be computed using the formulaarea = √(s(s–a)(s–b)(s–c))where t...

A: The C++ program will obey the following rubrics:Importing essential header files.Declaring integer d...

question_answer

Q: EXPLAIN ALL STEPS: Determine the output of the following Pep/9 machine language program if the input...

A: Address   Instruction(in hex)0000         D1FC15Convert the instructions into binary form-D=11011=00...

question_answer

Q: You are given a function called is_prime  which consumes a positive number and returns True if the n...

A: Before solving this question first, you should know some functions definitions :Prime number: Primar...

question_answer

Q: PHP  Think of one of your Math homework. How can you use program to reveal the answer? Write a calcu...

A: Program Instructions:The given program implements the Strassen’s method of multiplication between tw...

question_answer

Q: "Simon Says" is a memory game where "Simon" outputs a sequence of 10 characters (R, G, B, Y) and the...

A: Program Algorithm-STARTStep1:Import the essential headers.Step2: Declare the main function.Step3: De...

question_answer

Q: Forest and domain functional level means Windows Operating System version. true or false

A: The Forest functional level is used to enable features across all the domains inside the forest. It ...

question_answer

Q: PLEASE EXPLAIN ALL STEPSIn the following code, determine the value of the symbole this. Predict and ...

A: Explanation of given code:“this” is a variable.DECO this, d; The instruction DECO means Decimal outp...

question_answer

Q: Hello this is Java that I'm using. Im having a problem with my for loop not reading, using or printi...

A: Note:The program given in the question gets an error only when a random number series contains the s...

question_answer

Q: Write a program that simulates tossing a coin. Prompt the user for how many times to toss the coin. ...

A: Program Algorithm-STARTStep1  Import the essential java packages.Step2  Define a Class MainStep3  De...