Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

//PA 6 choice.cpp//This program illustrates how to use a value-returning//function to get, validate, and return input data.//PUT YOUR NAME HERE. # include using namespace std;//Function

image text in transcribed
//PA 6 choice.cpp//This program illustrates how to use a value-returning//function to get, validate, and return input data.//PUT YOUR NAME HERE. # include using namespace std;//Function prototype int getChoice();/***** main *****? int main () int choice; cout > input; while (input 4) {cout > input;} return input; Read through the code to see how it works. Notice that the getChoice function validates the input before returning it. Follow the directions given In the uppercase comments on lines 4 and 19-20. Then compile and run the program. When prompted for an input, use the data shown in the sample run below You should get the same results. Now make the getChoice function more versatile so it can validate that a choice is in any desired range, not just 1 -4. Do this by carrying out the following steps: bullet Add two integer parameters named min and max to the function header and modify the function prototype to agree with this. bullet Revise the function so that it now validates that the input is between min and max. Remember to change the error prompt as well as the test condition of the while loop. bullet Revise the line of code in main that calls the function so that it now passes two arguments to the function. Pass the values 1 and 4 to the function (though other values would work also)

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

Database In Depth Relational Theory For Practitioners

Authors: C.J. Date

1st Edition

0596100124, 978-0596100124

Students also viewed these Databases questions