Answered step by step
Verified Expert Solution
Link Copied!

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 36 user-input 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 36 functions created in parts 1-5 into one file. Put prototypes for all functions at the beginning of this
file. Copy/paste this file into your report ONCE. Create separate programs for questions 1-6 and copy/paste
EACH of these programs into your report with the appropriate test plans.
Part 1
Write an idiot-proofing 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 2
Overload the function from part 1, so that it
Maintains all functionality of part 1
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 3
Overload both functions from parts 1 & 2, 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 >=10(10 is minimum) or <=15(15 is maximum).
This is creating two new functions, so youll have a total of four functions when finished with part 3.
Part 4
Overload both functions from parts 1 & 2, 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?)
3
Example: you only want values between 10 and 20, or outside the range 5 to 10(<=5 or >=10).
This is creating two new functions, so youll have a total of six functions when finished with part 4.
Question 1
Create a test program to prove your six integer functions work.
Question 2
Create six new functions (different name from question 1, but all with the same new name) from question 1
functions so that they handle long data type instead. Create a test program to prove your six long functions
work.
Question 3
Create six new functions (different name from previous questions, but all with the same name) from question 1
so that they handle float data type instead. Create a test program to prove your six float functions work.
Question 4
Create six new functions (different name from previous questions, but all with the same name) from question 1
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 5
Create six new functions (different name from previous questions, but all with the same name) from question 1
so that they handle unsigned data type. Create a test program to prove your six unsigned functions work.
Question 6
Create six new functions (different name from previous questions, but all with the same name) from question 1
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

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

More Books

Students also viewed these Databases questions