Answered step by step
Verified Expert Solution
Question
1 Approved Answer
When you are finished with this assignment, you will have 3 6 user - input validation functions that you can use for years to come
When you are finished with this assignment, you will have userinput validation functions that you can use
for years to come when writing other programs!
All features possible must be tested for each function. These functions are meant to get input from the user,
validate it and return it; nothing more. Therefore, none of these functions may display any message or values
other than the original message and a request to try again. Remember, cin knows what data type its trying to
read and will return an error if the data type is wrong, so theres no need to read data as a string and parse it
yourself. You must provide function prototypes for every function.
Put the functions created in parts into one file. Put prototypes for all functions at the beginning of this
file. Copypaste this file into your report ONCE. Create separate programs for questions and copypaste
EACH of these programs into your report with the appropriate test plans.
Part
Write an idiotproofing function to get int values, returning the value using a return statement not reference
parameter Include a string parameter for a message that has a default parameter value appropriate for int
example: Please enter an integer The function must loop until valid input is entered, then return that valid
value. Display the message parameter when asking the user for input.
Part
Overload the function from part so that it
Maintains all functionality of part
Has function return type of bool not a parameter of bool indicating success or failure
Has a parameter, n for number of tries to attempt, with a default parameter value. If the user doesnt enter
valid input within n attempts then the function returns false. Return true if valid input is received within n
or fewer attempts.
Use a reference parameter to return the users entered value
As part of your test plan, you must test the bool return value in your calling function to validate that the value
came within n attempts
Part
Overload both functions from parts & so that they also
Maintain all existing functionality in two new functions.
Allow a programmer to specify either a minimum value or a maximum value as a parameter. All min
and max are to be inclusive values. How will the programmer tell the function a min value is wanted
vs a max value?
Example: you only want values is minimum or is maximum
This is creating two new functions, so youll have a total of four functions when finished with part
Part
Overload both functions from parts & so that they also
Maintain all existing functionality in two new functions.
Allow a programmer to specify a range of values as parameters, and whether the users input should be
between the values or outside the value range. All values are inclusive. How will the programmer tell
the function the values are within the range vs outside the range?
Example: you only want values between and or outside the range to or
This is creating two new functions, so youll have a total of six functions when finished with part
Question
Create a test program to prove your six integer functions work.
Question
Create six new functions different name from question but all with the same new name from question
functions so that they handle long data type instead. Create a test program to prove your six long functions
work.
Question
Create six new functions different name from previous questions, but all with the same name from question
so that they handle float data type instead. Create a test program to prove your six float functions work.
Question
Create six new functions different name from previous questions, but all with the same name from question
so that they handle char data type. All functions will also validate that the users input is alpha. Create a test
program to prove your six char functions work.
Question
Create six new functions different name from previous questions, but all with the same name from question
so that they handle unsigned data type. Create a test program to prove your six unsigned functions work.
Question
Create six new functions different name from previous questions, but all with the same name from question
so that they handle double data type. Create a test program to prove your six double functions work.
Step 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