Results 1 to 2 of 2
  1. #1
    jpnym15 is offline Member
    Join Date
    Nov 2007
    Posts
    19
    Rep Power
    0

    Default Help?...please?....

    Guess a Number
    This program generates a random integer between 1 and 100, including 1 and 100. It asks the user to guess the number. The user gets 10 guesses. After each guess, the program tells the user if the guess was too high or too low. If the user guesses within the 10 guesses, the user wins.

    Sample run

    Okay, Iíve got a number. What is your guess number 1?
    50
    Sorry, thatís too high.
    What is your guess number 2?
    25
    Sorry, thatís too low.
    What is your guess number 3?
    42
    Yes. That is the answer. You win!


    COULD SOMEONE POSSIBLY TELL ME HOW I WOULD GO ABOUT DOING A WHILE LOOP FOR THE 10 GUESSES.

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    9

    Default

    Java Code:
    public class PseudoCode {
        public static void main(String[] args) {
            int count = 0;
            boolean moreOfThis = true;
            do {
                // pick a random number
                // ask user to guess
                // check results
                if(successful)
                    ask if they'll have another go
                if(yes)
                    reset count
                else
                    break; _or_ moreOfThis = false;
            } while(moreOfThis);
        }
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •