Support Forums

Full Version: My second program: Guessing Game
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Code:
import java.util.*;
public class random
{
    public static void main(String[] args)
    {
        Scanner num = new Scanner(System.in);
        int guess;
        Random generator = new Random();
        int number = generator.nextInt(10);
        System.out.print("Guess a number?: ");
        guess = num.nextInt();
        if (number == guess)
            System.out.println("You Win!");
        else
            {
            System.out.println("You Lose...");
            System.out.print("The number was ");
            System.out.println(number);
            }
            
    }
}