Hey I'm having trouble with figuring out while loops for my homework. I suppose to prompt a user for a number for height between 3 and 10 (inclusive), and a number for width between the height and 20. If the user enters a number outside the criteria I'm suppose to use a while loop to prompt them to input the a correct number. This is the code I came up with but when I run it, it prompts for the height and width but if out of bounds it doesn't prompt to repeat. Not sure what I am doing wrong and any help is much appreciated.
#include <iostream>
#include <string>
#include <sstream>
usingnamespace std;
void main()
{
//define variables
int Width = 0;
int Height = 0;
//prompt user for height
cout << "Enter a box height(between 3 and 10):";
cin >> Height;
//prompt user fpr width
cout << "Enter a box width between (6 and 20): ";
cin >> Width;
//prompt user to repeat height if out of bounds
while (Height < 3 && Height > 10)
{
if (Height < 3 && Height > 10)
{
cout << "That number is out of bounds: Try again: ";
cin >> Height;
}
}
//prompt user to repeat width if out of bounds
while (Width <= Height && 20 >= Width)
{
if (Width <= Height && 20 <= Width)
{
cout << "That number is out of bounds: Try again: ";
cin >> Width;
}
}
}
#include <iostream>
#include <string>
#include <sstream>
usingnamespace std;
void main()
{
//define variables
int Width = 0;
int Height = 0;
//prompt user for height
cout << "Enter a box height(between 3 and 10):";
cin >> Height;
//prompt user fpr width
cout << "Enter a box width (between height and 20): ";
cin >> Width;
//prompt user to repeat height andd width if out of bounds
while (Height < 3 && Height > 10)
{
if (Height < 3 && Height > 10)
{
cout << "That number is out of bounds: Try again: ";
cin >> Height;
if (Width <= Height && 20 <= Width)
{
cout << "That number is out of bounds: Try again: ";
cin >> Width;
}
}
}
}