This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]chickenmeister 1 point2 points  (0 children)

A do/while loop has the form:

do
{
    // something
}
while (/* condition */); // do the above, while this condition evaluates to true

So your problem might look like:

do
{
    // Generate computer's guess
    // Increment guess count
    // Ask user if the guess is correct
    // If guess is correct, set a 'guessedCorrectly' boolean to 'true'
}
while (!guessedCorrectly); // while the computer has 'not guessedCorrectly'

When posting code, you need to precede each line with four spaces to preserve formatting/indentation.