Results 1 to 3 of 3
  1. #1
    ctkim is offline Member
    Join Date
    Nov 2013
    Posts
    2
    Rep Power
    0

    Default Reverse Number Guessing Game--in 10 tries???

    Hey all!

    So the concept is pretty simple. I wrote a program where the user thinks of a number and the computer tries to guess what the number is (between 1~1000). The user then says whether it's too high, too low, or correct.

    My program works great with no bugs, but the only part I'm struggling with is that I need to get the number of guesses to below 10.

    So far, I don't see how I can do that, since the numbers are being randomly generated from 1 ~ 1000, as I change the min and the max number according to the guesses and user input.

    Is there something I'm missing to see? Any ideas?

    Thanks so much!

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,601
    Rep Power
    5

    Default Re: Reverse Number Guessing Game--in 10 tries???

    What you want to do is essentially a binary search. So the computer guesses a number. From there you keep splitting the remaining range of numbers in half until the correct number is reached.

    Regards,
    Jim
    Last edited by jim829; 11-02-2013 at 01:41 AM.
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  3. #3
    ctkim is offline Member
    Join Date
    Nov 2013
    Posts
    2
    Rep Power
    0

    Default Re: Reverse Number Guessing Game--in 10 tries???

    Yes! Perfect.
    Thank you!

Similar Threads

  1. Help With Random Number Guessing Game
    By carlyspade in forum New To Java
    Replies: 15
    Last Post: 07-21-2013, 09:57 PM
  2. Number Guessing Game issue
    By gabrielpr12 in forum New To Java
    Replies: 14
    Last Post: 01-24-2012, 11:06 PM
  3. Reverse Number guessing game
    By rarman555 in forum New To Java
    Replies: 6
    Last Post: 04-24-2011, 01:46 AM
  4. Help with Reverse Guessing Game Code
    By koryvandell in forum New To Java
    Replies: 2
    Last Post: 04-04-2011, 01:53 AM
  5. Java - number guessing game
    By kev670 in forum Java Applets
    Replies: 3
    Last Post: 10-22-2010, 12:55 AM

Posting Permissions

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