Sorry, I shouldn't have used
enum - I just complicated things. You can use a simple loop. Loops are used to repeat code over again until a certain condition is met. Here's an analogy: You place a jug of beans within a microwave and then press the start button. While those beans aren't hot, wait until they are hot. This can be seen like this in code:
1 2 3 4 5
|
bool hot(false);
while(!hot)
{
// Wait until they are hot...
}
|
Now, you would use a loop to keep asking the user for input either if the input is wrong, or you need more. For example:
1 2 3 4 5 6 7
|
int input(0);
while(input < 100)
{
std::cout << "Enter a number greater than or equal to 100: ";
std::cin >> input;
}
|
This code will continue to ask the user to enter a value until their input is greater than or equal to 100. If it's not, the loop will ask the user again. The only time the loop will stop is when:
1) ...the user gets bored because they can't enter a number bigger than 100
2) ...when the computer rusts
3) ...when there's a power-cut
A
switch can appear within a loop. A
switch is used to handle specific values.
Wazzak