I'm not sure why count loops from zero to 4. Let us know your plan with that.
Do you intend to take the input 4 times, or draw 4 rectangles?
I sense this is not where your loop should be constructed.
The type for length and width should probably not be strings, because you use numeric input (even as a command for exit). The instructions tell you to use integers, so declare them as integers.
Look at points D and E, then focus on
E tells you to validate the LENGTH, loop if out of range or exit.
So, consider starting a loop that does not ever terminate unless length is valid (or 99 causes an exit).
You'll need to consider an error message, then re-print the instruction/request, perhaps something like:
1 2 3 4 5 6 7 8 9 10 11
|
while( length < 1 || length > 20 )
{
cout << "Enter a value from 1 to 20...\n";
cout << "Please enter the length of the rectangle <Enter 99 to Exit> > \n";
cin >> length;
if ( length == 99 ) return 0;
}
|
Assume length is an integer, and IT IS INITIALIZED TO ZERO.
This exits the program when 99 is entered.
It loops if length is not in the correct range.
If you get that much, reconsider the width input with something similar.