Advertisement
waytoofoxy

Untitled

Mar 29th, 2015
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.58 KB | None | 0 0
  1. import java.util.Random;
  2. import java.util.Scanner;
  3. public class Problem2 {
  4.     public static void main(String args[]){
  5.         Scanner input = new Scanner(System.in);
  6.         Random rand = new Random();
  7.         int number;
  8.         int guess = 0;
  9.         int counter;
  10.         number = rand.nextInt(100)+1;
  11.         while(guess!=number){
  12.         System.out.println("Pick a number from 1 to 100.");
  13.             guess = input.nextInt();
  14.             if(guess>number)
  15.                 System.out.println("Your guess is high.");
  16.             else if(guess<number)
  17.                 System.out.println("Your guess is low.");
  18.             else
  19.                 System.out.println("You guessed it.");
  20.         }
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement