menu
bartleby
search
close search
Hit Return to see all results

Code needed for the following: Use the final numerical grade to look up the corresponding letter grade as follows:90 - 100 = A80 -  89 = B70 -  79 = C60 -  69 = D<  60 = FUse the final letter grade to look up a "witty" comment of your choice, using a SWITCH statement. A statement must be output for each letter grade above.  For example:A = "Most excellent work”B = "IMHO You Passed"etc. Request an output file name from the user. Do not “hard-code” the file name in the program.  Do not “hard-code” the file name in the program.  Check to ensure the output file opens.  If it does not open, display an appropriate message to the user and exit the program.For each student, output the following to the console (screen) and the output file in a neat, readable format. Output each input line on one output line.  Use manipulators to output values in readable columns:Student Name, Total Points (numerical grade):  NN.  Letter Grade: X.  Depending on letter grade, The witty comment.Code written thus far: _______________________________________________________#include <iostream>#include <fstream>#include <iomanip>using namespace std;int main(){int totalGrades; // This is the total number of test gradesint grade; // This is the student's test gradeifstream inFile; // This is a declaration of the inFile that holds all the gradesstring fileName; // This is the filename that the user will enterstring name; // This is the name of the studentstring surname;int gradeCount; // This is to keep count of the number of grades enteredint hwGradesN; // Number of homework gradesint hwGradesV; // Homework grade valuesfloat hwGradesP; // Homework grade percentageint progGradesN; // Number of program gradesint progGradesV; // Program grade valuesfloat progGradesP; // Program grade percentageint examGradesN; // Number of exam gradesint examGradesV; // Exam grade valuesfloat examGradesP; // Exam grade percentageint totalHWpoints; // Total homework points earnedint totalProgpoints; // Total program points earnedint totalExampoints; // Total exam points earnedint maxHWpoints; // The maximum points available for homework gradesint maxProgpoints; // The maximum points available for program gradesint maxExampoints; // The maximum points available for exam gradesfloat finalGrade; // Final gradefloat average; // The average of all the gradescout << "Enter the input file name to read student grades: ";cin >> fileName;// Open the file with the gradesinFile.open(fileName.c_str ());// Check to make sure the file opened correctlyif (!inFile){cout << "File did not open correctly." << endl;return 1;}// Reads scores from file}while(!inFile.eof()){totalHWpoints=0;totalProgpoints=0;totalExampoints=0;inFile>>name;inFile>>surname;inFile>>hwGradesN;maxHWpoints = hwGradesN*100;while(hwGradesN--){inFile>>hwGradesV;totalHWpoints+=hwGradesV;}inFile>>hwGradesP;maxProgpoints = hwGradesP*100;inFile>>progGradesN;while(progGradesN--){inFile>>progGradesV;totalProgpoints+=progGradesV;}inFile>>progGradesP;inFile>>examGradesN;maxExampoints = examGradesN*100;while(examGradesN--){inFile>>examGradesV;totalExampoints+=examGradesV;}inFile>>examGradesP;finalGrade= (((totalHWpoints/maxHWpoints) * hwGradesP) + ((totalProgpoints/maxProgpoints) * progGradesP) + ((totalExampoints/maxExampoints) * examGradesP)) * 100;cout << "Final Grade of "<<name<<" "<<surname<<": " << finalGrade << endl;}  // Calculate the average.//average = (score1 + score2 + score3) / 300;// cout << << average << endl; // Display the average. // if (average>=90) finalGrade = 'A';// if (average<90 && average >=80 ) finalGrade = 'B';// if (average<80 && average >=70) finalGrade = 'C';// if (average<70 && average >=60) finalGrade = 'D';// if (average<=60) grade = 'F'; finalGrade = 'F';//// cout << "Final Grade: " << finalGrade << endl;return 0;}}

Question

Code needed for the following:

Use the final numerical grade to look up the corresponding letter grade as follows:

90 - 100 = A

80 -  89 = B

70 -  79 = C

60 -  69 = D

<  60 = F

Use the final letter grade to look up a "witty" comment of your choice, using a SWITCH statement. A statement must be output for each letter grade above.  For example:

A = "Most excellent work”

B = "IMHO You Passed"

etc.

 

Request an output file name from the user. Do not “hard-code” the file name in the program.  Do not “hard-code” the file name in the program.  Check to ensure the output file opens.  If it does not open, display an appropriate message to the user and exit the program.

For each student, output the following to the console (screen) and the output file in a neat, readable format. Output each input line on one output line.  Use manipulators to output values in readable columns:

Student Name, Total Points (numerical grade):  NN.  Letter Grade: X.  Depending on letter grade, The witty comment.


Code written thus far: 
_______________________________________________________
#include <iostream>
#include <fstream>
#include <iomanip>

using namespace std;

int main()

{
int totalGrades; // This is the total number of test grades

int grade; // This is the student's test grade

ifstream inFile; // This is a declaration of the inFile that holds all the grades

string fileName; // This is the filename that the user will enter

string name; // This is the name of the student

string surname;

int gradeCount; // This is to keep count of the number of grades entered

int hwGradesN; // Number of homework grades

int hwGradesV; // Homework grade values

float hwGradesP; // Homework grade percentage

int progGradesN; // Number of program grades

int progGradesV; // Program grade values

float progGradesP; // Program grade percentage

int examGradesN; // Number of exam grades

int examGradesV; // Exam grade values

float examGradesP; // Exam grade percentage

int totalHWpoints; // Total homework points earned

int totalProgpoints; // Total program points earned

int totalExampoints; // Total exam points earned

int maxHWpoints; // The maximum points available for homework grades

int maxProgpoints; // The maximum points available for program grades

int maxExampoints; // The maximum points available for exam grades

float finalGrade; // Final grade

float average; // The average of all the grades

cout << "Enter the input file name to read student grades: ";

cin >> fileName;

// Open the file with the grades

inFile.open(fileName.c_str ());

// Check to make sure the file opened correctly

if (!inFile)

{
cout << "File did not open correctly." << endl;
return 1;
}

// Reads scores from file
}

while(!inFile.eof()){

totalHWpoints=0;

totalProgpoints=0;

totalExampoints=0;

inFile>>name;

inFile>>surname;

inFile>>hwGradesN;

maxHWpoints = hwGradesN*100;

while(hwGradesN--){

inFile>>hwGradesV;

totalHWpoints+=hwGradesV;

}

inFile>>hwGradesP;

maxProgpoints = hwGradesP*100;

inFile>>progGradesN;

while(progGradesN--){

inFile>>progGradesV;

totalProgpoints+=progGradesV;

}

inFile>>progGradesP;

inFile>>examGradesN;

maxExampoints = examGradesN*100;

while(examGradesN--){

inFile>>examGradesV;

totalExampoints+=examGradesV;

}

inFile>>examGradesP;

finalGrade= (((totalHWpoints/maxHWpoints) * hwGradesP) + ((totalProgpoints/maxProgpoints) * progGradesP) + ((totalExampoints/maxExampoints) * examGradesP)) * 100;

cout << "Final Grade of "<<name<<" "<<surname<<": " << finalGrade << endl;

}

 

 

// Calculate the average.

//average = (score1 + score2 + score3) / 300;

// cout << << average << endl; // Display the average.

 

// if (average>=90) finalGrade = 'A';

// if (average<90 && average >=80 ) finalGrade = 'B';

// if (average<80 && average >=70) finalGrade = 'C';

// if (average<70 && average >=60) finalGrade = 'D';

// if (average<=60) grade = 'F'; finalGrade = 'F';

//

// cout << "Final Grade: " << finalGrade << endl;

return 0;
}
}

check_circleAnswer
Step 1

This C++ program obey the following rubrics: -

In main method – Declaring and initializing the variables according to their requirements

 

  • totalGrades for total number of test grades

 

  • Grade is the student's test grade

 

  • inFile holds all the grades

 

  • filename is that the user will enter

 

  • name is the name of the student

 

  • surname is surname of the student

 

  • gradeCount is to keep count of the number of grades entered

 

  • hwGradesN is number of homework grades

 

  • hwGradesV is homework grade values

 

  • hwGradesP is homework grade percentage

 

  • progGradesN is number of program grades

 

  • progGradesV is program grade values

 

  • progGradesP is program grade percentage

 

  • examGradesN is number of exam grades

 

  • examGradesV is exam grade values

 

  • examGradesP is exam grade percentage

 

  • totalHWpoints is total homework points earned

 

  • totalProgpoints is total program points earned

 

  • totalExampoints is total exam points earned

 

  • maxHWpoints is the maximum points available for homework grades

 

  • maxProgpoints is the maximum points available for program grades

 

  • maxExampoints is the maximum points available for exam grades

 

  • finalGrade is for Final grade

 

 

Functions:

  • open() function opens the text file provided by user.
  • Read data from file provided by user. Calculate the final grades using the given formula. Assign character grade value to these final grades using the information given.
  • Finally print the name, surname, total grades, character grade and appropriate comment according to the grades.
Step 2

#include <iostream> //header file for standard input output

 

 

#include <fstream> //header file to read and write data in file

 

 

using namespace std;

 

int main()

 

{

 

  int totalGrades; // This is the total number of test grades

 

  char Grade; // This is the student's test grade

 

  ifstream inFile; // This is a declaration of the inFile that holds all the grades

 

  string fileName; // This is the filename that the user will enter

 

  string name; // This is the name of the student

 

  string surname;

 

  int gradeCount; // This is to keep count of the number of grades entered

 

  int hwGradesN; // Number of homework grades

 

  int hwGradesV; // Homework grade values

 

  float hwGradesP; // Homework grade percentage

 

  int progGradesN; // Number of program grades

 

  int progGradesV; // Program grade values

 

  float progGradesP; // Program grade percentage

 

  int examGradesN; // Number of exam grades

 

  int examGradesV; // Exam grade values

 

  float examGradesP; // Exam grade percentage

 

  int totalHWpoints; // Total homework points earned

 

  int totalProgpoints; // Total program points earned

 

  int totalExampoints; // Total exam points earned

 

  int maxHWpoints; // The maximum points available for homework grades

 

  int maxProgpoints; // The maximum points available for program grades

 

  int maxExampoints; // The maximum points available for exam grades

 

  float finalGrade; // Final grade

 

  float average; // The average of all the grades

 

  cout << "Enter the input file name to read student grades: ";

 

  cin >> fileName;

 

  // Open the file with the grades

 

  inFile.open(fileName.c_str());

 

  // Check to make sure the file opened correctly

 

  if (!inFile)

 

  {

 

    cout << "File did not open correctly." << endl;

 

    return 1;

 

  }

 

  // Reads scores from file

 

  while (!inFile.eof()) {

 

    totalHWpoints = 0;

 

    totalProgpoints = 0;

 

    totalExampoints = 0;

 

    inFile >> name;

 

    inFile >> surname;

 

    inFile >> hwGradesN;

 

    maxHWpoints = hwGradesN * 100;

 

    while (hwGradesN--) {

 

      inFile >> hwGradesV;

 

      totalHWpoints += hwGradesV;

 

    }

 

    inFile >> hwGradesP;

 

    maxProgpoints = hwGradesP * 100;

 

    inFile >> progG...

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Our solutions are written by experts, many with advanced degrees, and available 24/7

See Solution
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: Draw a flowchart for a program that shows the logic for a program that generates a random number.  T...

A: The following program will generate a random number 0 or 1. If the generated random number is 0, the...

question_answer

Q: Who is Alan Turnig ?

A: Alan Turing was born in the year 1912 and died in the year 1954. He was a mathematician, computer sc...

question_answer

Q: What exactly is microcomputers sensored towards?

A: Microcomputer:Microcomputer is the small inexpensive computer which includes microprocessor, memory,...

question_answer

Q: Develop (separate) truth tables for the following equations: 1)  (A+B)(B+C) 2) (X*Y)*~(Z)3) (A+B) ⊕ ...

A: Truth table is used to simplify the Boolean expression in digital electronics. Number of gates used ...

question_answer

Q: a. Show that the disk moves made in the classic recursive algorithm for the Towers of Hanoi puzzle c...

A: a.Disk moves for Tower of Hanoi puzzle The disk moves that are made in the classic recursive algorit...

question_answer

Q: Is the file structure of Windows 10 File Explorer or hierarchy?

A: File structure of an operating system cannot be differentiated as file explorer or hierarchy.

question_answer

Q: Please help me solve this problem

A: Program design:Since the corner positions are a1,a8,h1,h8 in a chess board and the borders are any p...

question_answer

Q: Can a python programmer write a program that takes a picture of its own source code and then hides a...

A: Python is a general purpose, interpreted, high level programming language that is used for developin...

question_answer

Q: The extraterrestrials living in the planet Numerion revere a specific type of integers N. In particu...

A: Program code #1:

Sorry about that. What wasn’t helpful?