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
In Python, arrays are usually reserved for
Katen [24]
It would be the first one! Hope this helps have a great day
5 0
3 years ago
g Given a 5 by 5 matrix of all positive values, write a program to find and display the greatest product of the 2 adjacent value
Rom4ik [11]

Answer:

Check the explanation

Explanation:

% iterate through each column (outer loop) , then iterate rows-1 (inner loop)

%take product of adjacent rows

mat = input('enter 5 by 5 matrix : ');

[R,C] = size(mat);

max_prod =0;

for c =[1:C]

for r=[1:(R-1)]

temp = mat(r,c)*mat((r+1),c);

if max_prod<temp

max_prod=temp;

end

end

end

fprintf('Greatest product : %i\n', max_prod)

Kindly check the output in the attached image below.

7 0
4 years ago
c++ 2.30 LAB: Phone number breakdown Given a long long integer representing a 10-digit phone number, output the area code, prefi
Nady [450]

Answer:

#include <iostream>

using namespace std;

int main()

{

   //declare variable to store phone numbers,its area code, prefix and line number.

   long phone_number;

   int area_code, prefix,line_number;

   cout<<"Enter 10-digit phone number:"<<endl;

   //input 10-digit phone number

   cin>>phone_number;

   //logic to find area_code, prefix, and line_number.

   area_code = phone_number/10000000;

   prefix = (phone_number/10000)%1000;

   line_number = phone_number%10000;

   //output phone number in asked format.

   cout<<area_code<<"-"<<prefix<<"-"<<line_number<<endl;

   return 0;

}

Output:

Enter 10-digit phone number:

8005551212

800-555-1212

Explanation:

In the above program 10 digit phone number entered by user will be stored in the variable phone_number.

Then using this phone_number variable area_code, prefix, and line number are calculated using the following logic:

area_code = phone_number/10000000;

prefix = (phone_number/10000)%1000;

line_number = phone_number%10000;

Finally these area_code, prefix, and line_number are displayed with hyphen in between using cout statement.

5 0
3 years ago
Windows pe includes networking components and allows you to use current windows drivers for network connectivity.
4vir4ik [10]
Indeed it is very true
4 0
3 years ago
Jaboooo helloooo are u there
Fed [463]
?????????????????????
8 0
3 years ago
Read 2 more answers
Other questions:
  • If you have a list of words that you wish to make into a bulleted list, you must first highlight or ________ the words with your
    14·1 answer
  • Anyone wanna join a supercar/hypercar enthusiast's club?
    10·1 answer
  • 3. By eliminating data redundancy, you're enforcing data A. validation. B. integrity. C. consistency. D. accuracy.
    14·2 answers
  • 1. ________ is often defined as using illicit (illegal) drugs, or when the drug is alcohol, tobacco, or a legitimate drug (presc
    13·1 answer
  • Implement (in Java) the radixSort algorithm to sort in increasing order an array of integer positive keys. public void radixSort
    13·1 answer
  • Which is a software configuration management concept that helps us to control change without seriously impeding justifiable chan
    14·1 answer
  • Solesbee v. Balkcom (1950) was one of two cases that challenged the constitutionality of capital punishment prior to 1968. What
    10·1 answer
  • Which of the following is a major difference between XSS attacks and remote code exploits?
    15·1 answer
  • Which of the following are results of technological advancements and increased automation?
    6·2 answers
  • Suppose that the five measured SampleRTT values are 106 ms, 120 ms, 140 ms, 90 ms, and 115 ms.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!