Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Inputs Each time through the program's main loop, the program will prompt the user and take in a C-Style string that is in one

The Inputs

Each time through the program's main loop, the program will prompt the user and take in a C-Style string that is in one of five forms:

1. a single numerical grade as a floating point number that represents the student's final mark a. allowable range is from 0.0 to 100.0 anything outside this range must be flagged as an error

2. a letter grade which is meant to represent the students final grade a. allowable values are A+, A, B+, B, C+, C, D, F, I, Q, AU, DNA, I/P any other letter grade input must be flagged as an error

3. from one to five integer values which represent the student's mark on each of five assignments worth 20% each, separated by spaces

a. allowable range for each mark is from 0 to 100 anything outside this range must be flagged as an error and invalidates all other assignment marks

b. Sample (valid) input might be :

80 70 65 80 60 >>> which results in a final output statement: Student achieved 71.00 % which is a PASS condition.

80 90 50 >>> which results in a final output statement: Student achieved 44.00 % which is a FAIL condition.

4. a single character, 'X', that indicates that the user wants to exit the program

5. a single character, Z followed by a space and then the name of a file which contains some user input (format of file discussed below)

Please note that this is not a menu-based program. That is, you are not to ask the user what type of grade they want to enter. You must take their input (from the 5 different types above) and determine what type of input they specified.

The only prompt that you should have for the user is Enter Students Grade(s) >>>

This means you need to develop a function which intelligently parses their input to determine if they have entered a single floating-point value, a single letter grade, assignment marks (1 to 5 integers), the letter X (to quit) or the letter Z (followed by a space and a filename)

As mentioned previously, you must create this user input parsing function (called parseUserInput()) to take user input as a CStyle string, examine the contents of the string (i.e. how can you tell if the user entered a floating point number? How can you tell if the user entered one or more integers? ) and once youve determined what kind of input it is and extracted the content from the input string you call the appropriate overloaded assessGrade() function with the extracted data.

Design Thoughts

In this assignment here are the guidelines on what logic you are allowed to place in your main() function:

1. You must prompt the user for input and receive the input

2. Then you look at the input to determine if the user entered X and allow the program to exit

3. If not X then look at the input and determine if the user is trying to specify an input test file. And if so, then your main function is allowed to open the file, read each test line of input and send it through the parsing and overloaded functions as if the user entered the input at the keyboard

o For example if the user enters Z myTestFile.dat

o Then you will code the appropriate File I/O calls to open the file called myTestFile.dat and read each test line out the file (passing it into your parseUserInput() as input) and once you reach the end of the file, close it and once again prompt the user for input. [Remember to do your adequate File I/O error checking]

2. If not X or Z then pass the user input into parseUserInput() for further processing

Remember that you must cycle through these steps in main() until the user enters X to exit the program

The Output

After your parseUserInput() function determines what kind of input the user entered and extracted the data from the users input string you will need to call one of the three overloaded assessGrade() functions (with the extracted data) in order to see if the student passed, failed, or had a special situation.

If the student passes or fails, display a line that gives the numerical value of the mark and an indication as to whether the student passed or failed. A mark of 54.50% or higher is required in order to pass. Your programs output must look like this: 5 Student achieved ###.## % which is a PASS condition. or Student achieved ###.## % which is a FAIL condition.

For example:

o Student achieved 100.00 % which is a PASS condition.

o Student achieved 45.23 % which is a FAIL condition.

Important Notes:

The two lines above will be the only allowed output from your program with the exception of

o Special Situations (as noted below) o Any error messages that you need to output from your program (errors due to out of range values or File I/O function calls)

Also note that in all input cases (the final grade, the letter grade and the assignment marks) the program will output the grade as a floating point number (up to 2 decimal places)

When testing your program, I will only include correctly formatted input data. This doesnt mean that Ill only be using valid values (i.e. values within the acceptable ranges) it means that I will not be trying to trick your parsing function.

For example:

o an acceptable floating point number may be 60.5 or 12500.6 or -12.76

o an acceptable alpha-only input may be A+, I/P or Hello

o an acceptable set of integers may be 1 2 3 or 673 -23 70 30 20

o What this means that I will not test with incorrectly formatted data like the following. (So you do not have to check for input formatted like this)

o I will not test with data like 6A.4, 64.4.3, 10 20 30 40 50 60 70, !+, 50 A+ 30 45.2, A +,

In no inputs case will there be any trailing spaces so your solution should not depend on having trailing spaces

If the users input is invalid (i.e. not an acceptable floating point value, alpha value or integer assignment value(s)) then simply output the following error statement: **ERROR : Invalid Input.

If you detect an issue when calling one of your File I/O functions you can simply output the following error statement ** File I/O ERROR

Special Situations

Special situations are denoted by the letter grades as follows:

Letter Grade Meaning

I Incomplete, Q Withdrawal After Drop/Refund Date, AU Audit Condition, DNA Did Not Attend, I/P In Process

If there is a special situation, then the output would show the information as follows:

Student has Special Situation : AU (Audit Condition)

For display purposes, the numerical equivalents for the letter grades are:

Letter Grade Numerical Equivalents

A+ 95

A 85

B+ 77

B 72

C+ 67

C 62

D 57

F 50

Input Test File Format

The input test file will always be an ASCII file (human readable). The format of the file is quite simple there will be one input per line in the file. This means that for each line you read out of your file you will need to pass it through the parseUserInput() function in order to process it.

Each line in the file will contain a trailing carriage return and each line in the file is guaranteed of being 80 characters or shorter. Here is an example file (you can create your own test file when writing/debugging your solution)

78.2383

12 66 88

A+

DNA

Hello

-88.2

78 34 -88

This is the output that would result from running this file through your program:

Student achieved 78.24 % which is a PASS condition.

Student achieved 33.20 % which is a FAIL condition.

Student achieved 95.00 % which is a PASS condition.

Student has Special Situation : DNA (Did Not Attend)

**ERROR : Invalid Input *

*ERROR : Invalid Input *

*ERROR : Invalid Input

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

Mysql Examples Explanations Explain Examples

Authors: Harry Baker ,Ray Yao

1st Edition

B0CQK9RN2J, 979-8872176237

More Books

Students also viewed these Databases questions

Question

Have I incorporated my research into my outline effectively?

Answered: 1 week ago