Question
Task 1 Write overloaded functions named inputVal() that prompt the user for a floating-point number and validate it using the valid ranges given in the
Task 1
Write overloaded functions named inputVal() that prompt the user for a floating-point number and validate it using the valid ranges given in the parameter set.
Use the following function prototypes:
double inputVal(string min, double max);
o Parameters:
string min: the actual string does not matter, indicates no lower limit
double max: upper limit
o Return value: validated user input
double inputVal(double min, string max);
o Parameters:
double min: lower limit
string max: the actual string does not matter, indicates no upper limit
o Return value: validated user input
double inputVal(double min, double max);
o Parameters: string min: lower limit
double max: upper limit
o Return value: validated user input
Consider the following code, which calls these functions:
double solidtemp = inputVal("none", 32.0); // solidtemp
double liquidtemp = inputVal(32.0, 212.0); // 32
double gastemp = inputVal(212.0, "none"); // 212
Write a program named inputvalidation.cpp that:
Tests the three functions
Contains a sample execution of the program in the source code using a multi-line comment (include invalid user inputs)
Task 1 Sample Output Please enter a number (min: no limit, max: 32) 100 Invalid input, try again! Please enter a number (min: no limit, max: 32) -123123 Please enter a number (min 32, max: 212): 0 Invalid input, try again! Please enter a number (min: 32, max: 212) 300 Invalid input, try again! Please enter a number (min 32, max: 212) 100 Please enter a number (min: 212, max: no limit) 100 Invalid input, try again! Please enter a number (min: 212, max: no limit) -100 Invalid input, try again! Please enter a number (min: 212, max: no limit) 212Step 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