1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
stealth61 [152]
3 years ago
12

Write a C++ program that computes student grades for an assignment as a percentage given each student's score and the total poin

ts. The final score must be rounded up to the nearest whole value using the ceil function in the header file and displayed as a percentage. You must also display the floating-point result up to 5 decimal places. You must use at least 2 functions: one to print the last name of the student and another function to compute and print the percentage as well as "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. The main function is responsible for reading the input file and passing the appropriate arguments to your functions.
Computers and Technology
1 answer:
aivan3 [116]3 years ago
8 0

Answer:

See Explaination

Explanation:

/ Header files section

#include <iostream>

#include <fstream>

#include <iomanip>

#include <string>

#include <cmath>

using namespace std;

// start main function

int main()

{

// variables declaration

string fileName;

string lastName;

double score;

double total;

double grade;

string description;

// prompt the user to enter the input file name

cout << "Enter the input file name: ";

cin >> fileName;

// open the input file

ifstream infile;

infile.open(fileName);

// exit from the program if the input file does not open

if (!infile)

{

cout << fileName << " file cannot be opened!" << endl;

exit(1);

}

// repeat the loop for all students in the file

infile >> lastName;

while (infile)

{

infile >> score;

infile >> total;

// compute the grade

grade = score / total * 100;

// find the grade's description

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";

else

description = "Fail";

// display the result of each student

cout << lastName << " " << setprecision(0) << fixed << round(grade) << "% " << setprecision(5) << fixed << (grade * 0.01) << " " << description << endl;;

infile >> lastName;

}

// close the input file

infile.close();

system("pause");

return 0;

} // end of main function

You might be interested in
Which is an example of correct HTML? &lt;h1&gt; This is a heading&lt;/h1&gt;
denis23 [38]

Answer:

An HTML tag is a special word or letter surrounded by angle brackets, < and >. You use tags to create HTML elements , such as paragraphs or links.

Explanation:

Many elements have an opening tag and a closing tag — for example, a p (paragraph) element has a <p> tag, followed by the paragraph text, followed by a closing </p> tag. HTML Editors

Step 1: Open Notepad (PC) Windows 8 or later: ...

Step 1: Open TextEdit (Mac) Open Finder > Applications > TextEdit. ...

Step 2: Write Some HTML. Write or copy the following HTML code into Notepad: ...

Step 3: Save the HTML Page. Save the file on your computer. ...

Step 4: View the HTML Page in Your Browser. hope this helps you :) god loves you :)

4 0
3 years ago
Read 2 more answers
Why is monitoring email, voice mail, and computer files considered legal?
Sati [7]

Explanation:

Monitoring someone's emails,voice mails and computer files is considered is illegal because you are accessing someone's personal information which is not regarded as  ethical .

There are certain reasons where one's email,voice mails and computer files can be monitored are as following:

  1. Protect the security information and security.
  2. Investigation of complaints of harassment.
  3. Preventing personal use of employer's facilities.
6 0
3 years ago
Fill in the code to complete the following method for checking whether a string is a palindrome. public static boolean isPalindr
Ilia_Sergeevich [38]

Answer:

(s.charAt(0) != s.charAt(s.length()-1))

Explanation:

public class Palindrome

{

public static void main(String[] args) {

   

    System.out.println(isPalindrome("car"));

    System.out.println(isPalindrome("carac"));

 

}

   public static boolean isPalindrome(String s) {

       if (s.length() <= 1)

           return true;

       else if (s.charAt(0) != s.charAt(s.length()-1))

           return false;

       else

           return isPalindrome(s.substring(1, s.length() - 1));

   }

}

You may see the whole code above with two test scenarios.

The part that needs to be filled is the base case that if the character at position 0 is not equal to the character at the last position in the string, that means the string is not a palindrome. (If this condition meets, it checks for the second and the one before the last position, and keeps checking)

4 0
3 years ago
What is the most common type of communication?
tamaranim1 [39]

Answer:

technology texting

Explanation:

omega lol

6 0
3 years ago
I think these might be the answers but im not to sure, so am I right? or wrong? please help
mina [271]
Number 1 and 4 are the same? I agree with your answers.
4 0
3 years ago
Read 2 more answers
Other questions:
  • True or False? A supervisory control and data acquisition (SCADA) device is a computer that controls motors, valves, and other d
    13·1 answer
  • Which technology was used in fourth generation of computer​
    13·2 answers
  • Write a routine to interchange the mth and nth elements of a singly-linked list. You may assume that the ranks m and n are passe
    10·1 answer
  • Voltage drop across the resistor
    9·1 answer
  • All NATE specialties are offered at two levels, A. journeyman and master. B. installation and service. C. apprentice and journey
    7·1 answer
  • HELP ME PLEASEEEE
    8·1 answer
  • Wassup anybody tryna play 2k
    6·2 answers
  • Be your self today!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    9·1 answer
  • Why is UPS necessary to connect with the computer​
    11·1 answer
  • This isn't academic, but what do I do if HI-REZ won't let me sign into an existing account. “Something went wrong” keeps popping
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!