Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. function start() {
  2. println(" This program plays a guessing game. ");
  3. println(" The computer is thinking of a value between 0 and 100 ");
  4. println(" Type '-1' to exit the program ");
  5.  
  6. var num = Randomizer.nextInt(0,100);
  7. while(true){
  8. var guess = readLine(" What is your guess? ");
  9.  
  10.  
  11. if(guess > num){
  12. println(" Your guess was too high. ");
  13. }
  14.  
  15. if(guess < num){
  16. println(" Your guess was too low. ");
  17. }
  18.  
  19. if(guess == num){
  20. println(" Correct!" );
  21. break;
  22. }
  23. if(guess == -1){
  24. break;
  25. println(" Game has concluded.");
  26. }
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement