// function and driver program // funtion to get color from user #include #include using namespace std; // function declaration int color(); int scale(); int main() { clog << "Calling function color() \n"; int thevalue(0); thevalue = color(); cout << "The function has returned " << thevalue << '\n'; clog << "Calling function scale() \n"; int thescale(0); thescale = scale(); cout << "The function has returned " << thescale << '\n'; } // function definitions int color() { int passback(0); int mycolor(0); // test to make sure mycolor is in range // if it is less than zero or if it is greater than 255 bool test(false); do { cout << "Input a number 0 to 255 for color \n"; cin >> mycolor; if (mycolor >= 0) test = false; if (mycolor <= 255) test = false; if (mycolor < 0) { // out of range ask for another value cout << "This is out of range. Please input a value between 0 and 255\n"; test = true; } if (mycolor > 255) { // out of range ask for another value cout << "This is out of range. Please input a value between 0 and 255\n"; test = true; } } while (test == true); test = false; if (test == false) passback = mycolor; return mycolor; } // write function definition for scale here int scale() { int passback(0); int myscale(0); // test to make sure myscale is in range // if it is less than 1 or if it is greater than 64 bool test(false); do { cout << "Input a number 1 to 64 for scale \n"; cin >> myscale; if (myscale >= 1) test = false; if (myscale <= 64) test = false; if (myscale < 1) { // out of range ask for another value cout << "This is out of range. Please input a value between 1 and 64\n"; test = true; } if (myscale > 64) { // out of range ask for another value cout << "This is out of range. Please input a value between 1 and 64\n"; test = true; } } while (test == true); test = false; if (test == false) passback = myscale; return myscale; }