All pastes #2070726 Raw Edit

Untitled

public text v1 · immutable
#2070726 ·published 2011-05-28 05:02 UTC
rendered paste body
package assi2question1;
import java.util.Scanner;
public class Assi2question1 {

    public static void main(String[] args) {
        int random, userInput;
        
        userInput = -1;
        random = (int)(100.0 * Math.random());
        
        System.out.println(random);
        
        Scanner keyboard = new Scanner(System.in);
        
        System.out.println("Guess an integer number between 0 and 100");

        while (random != userInput)  {
           userInput = keyboard.nextInt();
           if ((random < 0) || (random > 100)){
                System.out.println(userInput + " is out of the range of 0 to 100. Guess again within the correct range.");
           }
           else if ((userInput < random ) && (userInput >= 0)) {
                System.out.println(userInput + " is too low. Guess a higher number");
           }
           else if ((userInput > random) && (userInput <=100)) {
                System.out.println(userInput + " is too high. Guess a lower number.");
           }
        }
        System.out.println("Congratulations, " + random + " is the number I picked.");
    }       
}