Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

//What's wrong with my code? Letter grades are A B C D and F, possibly followed by + or - Their nu- meric values are

//What's wrong with my code?

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Letter grades are A B C D and F, possibly followed by + or - Their nu- meric values are 4, 3, 2, 1 and O. In our scheme, there is no F+ or F-, or Ar. Adding a + to the grade increases the numeric value by 0.3, a-de- creases it by 0.3. 15 // Function Prototypes 16 void printTitle(); 17 string getInput(); 18 double letterToPoints(stringIn letterGrade); 19 void printReport(double points); 20 21 // Constants 22 const double INVALID_COMBINATION = -1.0; 23 const double INVALID_INPUT = -2.0; 25 /** * Calculates the grade points for a letter grade. 27 * @return for success. 28 */ 29 int run() 30 { // Don't change anything inside this function printTitle(); string letterGrade = getInput(); double points = letterToPoints (letterGrade); printReport(points); 31 return 0; 40 // Implement your functions here 42 void printTitle() 43 { cout > gradeIn; return gradeIn; 56 double letterToPoints (stringin letterGrade) double gradePoints = -1; if (gradeIn == "A") gradePoints = 4.0; else if (gradeIn == "A-") gradePoints = 3.7; else if (grade In == "B+") gradePoints = 3.3; else if (gradeIn == "B") gradePoints = 3.0; else if (grade In == "B-") gradePoints = 2.7; else if (grade In == "C+") gradePoints = 2.3; else if (grade In == "C") gradePoints = 2.0; else if (gradeIn == "C-") gradePoints = 1.7; else if (gradeIn == "D+") gradePoints = 1.3; else if (gradeIn == "D") gradePoints = 1.0; if (grade In == "A") gradePoints = 4.0; else if (gradeIn == "A-") gradePoints = 3.7; else if (grade In == "B+") gradePoints = 3.3; else if (grade In == "B") gradePoints = 3.0; se if (grade In == "B-") gradePoints = 2.7; else if (grade In == "C+") gradePoints = 2.3; se if (gradeIn == "C") gradePoints = 2.0; else if (gradeIn == "C-") gradePoints = 1.7; else if (gradeIn == "D+") gradePoints = 1.3; else if (gradeIn == "D") gradePoints = 1.0; else if (gradeIn == "D-") gradePoints = 0.7; else if (gradeIn == "F") gradePoints = 0.0; return 0.0; 74 void printReport(double points) 75 { cout = 0) cout = 1 && gradeIn.at() != 'A' && gradeIn.at() != 'B' && gradeIn.at(0) != 'C' && gradeIn.at(0) != 'D' && gradeIn.at(0) != 'F) errorMessage = "INVALID LETTER GRADE"; else errorMessage= "Invalid Input" ; 24:1 C and C++ Tabs: 4

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2012 Administration

Authors: Adam Jorgensen, Steven Wort

1st Edition

1118106881, 9781118106884

More Books

Students also viewed these Databases questions

Question

Question Can life insurance be used in a Keogh (HR 10) plan?

Answered: 1 week ago