Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The programming language is C++ COSC 1336, M8e PA4 Library Functions: readChar and getArea Reusable User-Defined Functions, Default Arguments and Function Overloading Create two new
The programming language is C++
COSC 1336, M8e PA4 Library Functions: readChar and getArea Reusable User-Defined Functions, Default Arguments and Function Overloading Create two new generic, reusable functions to add to your library The test driver program will use your previously coded generic, reusable readint and readDouble functions Do NOT modify these two existing functions Code these new function prototypes in your library.h file and their definitions in your library .cpp file eadChar Function 1. The readChar function will be a value returning function designed to get a single char value from the user and return it as an upper case character. The function will validate that the character received is one of two possible character entries Examples of using the function could be to prompt the user to answer a question by entering 'Y' or 'N' for yes or no select a gender by entering 'F' or 'M' for female or male select a student classification by entering 'F' or 'S' for freshman or sophomore selecting an object's shape by entering 'R' orfor rectangle or circle Model this function's header (interface) after the readlnt function where it has three parameters for an error message and a character 1 and a character 2 Example call when an invalid character is entered the error message would be 2. char gender = readchar("Gender",'F','M') Errorl Invalid input. Gender must be either F or M. Try Again Use Default Arguments in the prototype. Be prepared to discuss your choice for these default values in class. Can you use them in your test driver program (see Step 7)? Model the function's definition body after the readint function using a do while loop to read the character and validate it providing an error message for invalid data to the user as indicated above The user may enter either lower or upper case characters but the function should return a valid character in upper case. Therefore, after reading in the character, use a call to the cctype library toupper function (Ch, pg.350) to convert the user's entry to upper case 3. someChar toupper(someChar); When testing, use test calls with lower case characters as arguments for only one and for both characters. Because valid entries will not typically be in a continuous range of values, but only one of two values, you will need to modify the validating code line to replace the relational (-) operators with the equality (=-) operator replace the logical and (&&) operator with the logical or(I) operator Include full function documentation- again model after the readint function documentation but make necessary modifications that accurately reflect this function. For more examples see the Function Documentation handout in the Week 4 module 4. 2/5/2018Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started