Assignemnt #61 and Keep Guessing
Code
import java.util.Random;
import java.util.Scanner;
public class KeepGuessing
{
public static void main( String[] args )
{
Random r = new Random();
int number, guess;
number = 1 + r.nextInt(10);
Scanner keyboard = new Scanner(System.in);
System.out.println("Let's play a Guessing Game!");
System.out.println();
System.out.println("Im thinking of a number between 1-10, try to guess it!");
guess = keyboard.nextInt();
while (guess != number )
{
System.out.println(" Come on, you aren't really this dumb right?!" );
System.out.print("Try again: " );
guess = keyboard.nextInt();
}
System.out.println("Good Job! You are actually capable unlike many other people who play this game.");
}
}
Picture of the output