Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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)

image text in transcribed

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) 212

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

Refactoring Databases Evolutionary Database Design

Authors: Scott Ambler, Pramod Sadalage

1st Edition

0321774515, 978-0321774514

More Books

Students also viewed these Databases questions

Question

8. Providing support during instruction.

Answered: 1 week ago