11-29-2009, 07:24 PM
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);
}
}
}