Number Guessing Game

I am a student studying computer science and I have this as first assignment, the computer as to make guesses for the secret number.
Hopefully someone can help me! :)

The Assignment

The game to play is a well known number guessing game. Alice asks Bob to pick a secret number between 1 and 15. When Bob has selected his number, Alice will guess it. If Alice's guess is correct Bob will respond “You win”. If his secret number is lower than Alice's guess, Bob will reply “lower”, and Alice will guess again. If his number if higher, he will respond “higher”, and Alice will guess again. If the number is correct, Bob will reply “You win”, Alice wins, and the game is over. If Alice does not find the correct number within 10 attempts, she gives up, and Bob wins.

The task is to write a program that plays for Alice. This means, your program will repeatedly guess Bob's secret number, print the guess to standard output, reads Bob's answer from standard input, and give up after 10 failed attempts

Last edited on
Loop until ten attempts or only one number left
is number half of the left numbers?
loop until ten attempts...
In fact to find the secret number it is enough only 4 attempts.:) For very "clever players" you can provide 5 attempts.
hey guys don't worry about it, i have done the program using rand and will put the program up, only need to figure out how the program needs to detect cheats..so i guess i'l need help there..and thank you for this website...its a really good help :)
Topic archived. No new replies allowed.