Lab 7.4 - C++ Code and Input Validation Critical Review
Numeric validation loops in C++ are done by writing the types of loops you already are familiar with. Code using a prime read might look as follows:
cout << "Enter a number between 1 and 10: ";
cin >> number;
while (number < 1 || number > 10) {
cout << "Invalid value" << endl;
cout << "Enter a number between 1 and 10: ";
cin >> number;
}
The goal of this lab is to convert the getTotalBottles function with input validation in the previous step to C++ and test it in a simple driver program. Make a call to the function getTotalBottlesO and assign the result to a variable myBottles in the main function. Print myBottles to test the function. Try it out for 7 days with valid values and invalid values as input. Try the following values: 5, 3, -1, 0, 4, 3, -5, 5, 2. The output would be 22 bottles. When your code is complete and runs properly, capture the output. Copy/paste both the source code and the output.