Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function start() {
- println(" This program plays a guessing game. ");
- println(" The computer is thinking of a value between 0 and 100 ");
- println(" Type '-1' to exit the program ");
- var num = Randomizer.nextInt(0,100);
- while(true){
- var guess = readLine(" What is your guess? ");
- if(guess > num){
- println(" Your guess was too high. ");
- }
- if(guess < num){
- println(" Your guess was too low. ");
- }
- if(guess == num){
- println(" Correct!" );
- break;
- }
- if(guess == -1){
- break;
- println(" Game has concluded.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement