Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is the start code I'm confusing how to get started, full answer will be appreciated tho 6 #include 7 #include 8 #include 9 using

This is the start code

I'm confusing how to get started, full answer will be appreciated tho

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

6 #include 7 #include 8 #include 9 using namespace std; 10 using stringIn = const string&; 11 12 13 extern string ASSIGNMENT; 14 15 void printTitle(); 16 string getInput(); 17 double letterTopoints(stringIn letterGrade); 18 void printReport(double points); 19 20 // Constants 21 const double INVALID_COMBINATION = -1.0; 22 const double INVALID_INPUT = -2.0; 23 24 /** 25 * Calculates the grade points for a letter grade. 26 * @return for success. 27 28 int run() 29 { 30 // Don't change anything inside this function 31 32 printTitle(); 33 string letterGrade = getInput(); 34 double points = letterToPoints(letterGrade); 35 printReport(points); 36 37 return; 38 } 39 40 41 Homework 3 A Grade Calculator grade into a numeric grade point. Here are the details: that translates a letter Letter grades are A, B, C, D, and F, possibly followed by + or - Their numeric values are 4, 3, 2, 1, and 0. In our scheme, there is no F+ or F-, or A+. Adding a + to the grade increases the numeric value by 0.3,a- decreases it by 0.3. If the letter grade is illegal (such as "Z"), then your output should be "INVALID LETTER GRADE"; If the combination is illegal (such as "A+" or "F-") then your output should be "INVALID GRADE COMBINATION"; if there is some other problem with the input, such as too many characters or an invalid symbol (A?), then use "INVALID INPUT". Step 1 - Mock up the Interaction Here is what the program should look like when it runs: sgilbert-H02-Grade Calculator Enter your letter grade: C+ Grade value is [2.3] Go ahead and add the comments to the starter code and use the cout object to pro- duce the output shown in the mockup. As you've done in the previous assignments, remember to separate the input and output values from text that remains unchanged. | Step 2 - Read the Input Ask the user to input a grade, like A or B, along with an optional plus or minus. You can't simply read two characters because the user may not need to enter two, (if there is no plus or minus). STEP 3 PROCESSING THE INPUT PAGE 2 How do you enter a variable number of characters? By using a variable of type string. The string class is defined in the library; you must include this li- brary in any program that manipulates string data. #include using namespace std; Although you might expect >> to read a line of input, the extraction operator actually stops as soon as it hits the first whitespace character, which is any character that ap- pears as blank space on the display screen; this includes spaces, tabs and newlines. The string getline Function To read a line of text, use the string function getline(). getline (cin, name); Create a string variable (I called mine gradeIn) and read the user's input using the getline() function. Here's what your code should look like: // 2. Input section cout 1.7 + Input of D+->1.3 + Input of D->1. + Input of D-->0.7 X Input of Abcdefg: expected (INVALID INPUT) but found (-1.0] X Input of D?: expected [INVALID INPUT] but found [-1.00 ---------------------------------------------- HO3-515: sgilbert:ALL TESTS -- PASS 8/13 (62%). Handling the Postcondition A postcondition is a condition that must always be true just after the execution of some section of code or after an operation in a formal specification. You know that the vari- able gradePoints must be >= 0. if your conversion succeeded. 1. A floating point number if the grade combination istegal (CH) 5. "INVALID LETTER GRADE" if the letter is illegal ("Z") 6. "INVALID GRADE COMBINATION" if the combination is illegal "A+" or "F-") 7. "INVALID INPUT" if there is some other problem with the input Planning an Output Solution Since you have several different error possibilities, use code like this: If grade points is = 0 Print the correct grade point Else If grade input is "A+" or "F+" or "F-" Print invalid grade combination Else If the gradeInput length is >= 1 and the first character is not in the set A,B,C,D,F Print the invalid letter grade message Else Print invalid input 1 http://en.wikipedia.org/wiki/Postcondition 45 + HOMEWORK 3 A GRADE CALCULATOR You can implement the first of these nested conditional statements, easily, like this: // 4. Output section cout = 0) { cout

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_2

Step: 3

blur-text-image_3

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2022 Grenoble France September 19 23 2022 Proceedings Part 4 Lnai 13716

Authors: Massih-Reza Amini ,Stephane Canu ,Asja Fischer ,Tias Guns ,Petra Kralj Novak ,Grigorios Tsoumakas

1st Edition

3031264118, 978-3031264115

More Books

Students also viewed these Databases questions

Question

proud of something in particular?

Answered: 1 week ago