Question: Develop a C++ template function that performs data validation of user input as follows: The function name is UserInputAndValidationFunction The function accepts three parameters: String
Develop a C++ template function that performs data validation of user input as follows:
- The function name is UserInputAndValidationFunction
- The function accepts three parameters:
- String of what the input prompt is (Enter an integer value between 0 and 100:)
- Templated type of what is the lowest possible input (0)
- Templated type of what is the highest possible input (100)
- Get user input of the templated type
- If the user inputs in the correct range, return the templated type input value
- If the user inputs outside of the correct range, throw an std::exception object
Develop a main() function that does the following:
- Use function UserInputAndValidationFunction to get user input
- Continue prompting the user for input until a value in the correct range is given
- Catch all exceptions as they are thrown by UserInputAndValidationFunction
- Do everything once with templated type int
- Do everything once with templated type double
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
