home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / libbasic / hilo.bas < prev    next >
BASIC Source File  |  1993-02-22  |  883b  |  47 lines

  1.  
  2.  
  3.     ' Here is an interactive HI-LO
  4.     ' Program
  5.  
  6. [start]
  7.  
  8.     guessMe = int(rnd(1)*100)
  9.  
  10.     cls
  11.     print "HI-LO"
  12.  
  13.     print
  14.  
  15.     print "I have decided on a number between one"
  16.     print "and a hundred, and I want you to guess"
  17.     print "what it is.  I will tell you to guess"
  18.     print "higher or lower, and we'll count up"
  19.     print "the number of guesses you use."
  20.  
  21.     print
  22.  
  23. [ask]
  24.  
  25.     count = count + 1
  26.     print "OK.  What is your guess?"
  27.     input guess
  28.  
  29.     if guess = guessMe then [win]
  30.  
  31.     if guess < guessMe then print "Guess higher."
  32.     if guess > guessMe then print "Guess lower."
  33.     goto [ask]
  34.  
  35. [win]
  36.  
  37.     beep
  38.     print "You win!  It took "; count; " guesses."
  39.     count = 0
  40.  
  41.     input "Play again (Y/N)?"; play$
  42.     if instr("YESyes", play$) then [start]
  43.  
  44.     print "Press ALT-F4 to close this window."
  45.  
  46.     end
  47.