Assignment #61
Code
/// Name: Ian Stanko
/// Period: 5
/// Program Name: KeepGuessing
/// File Name: KeepGuessing.java
/// Date Finished: 1/4/2016
import java.util.Random;
import java.util.Scanner;
public class KeepGuessing
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
Random r = new Random();
int guess, n;
n = 1+r.nextInt(10);
System.out.println("worst game ever");
System.out.println("");
System.out.print("Guess a number between 1-10. ");
guess = keyboard.nextInt();
System.out.println("");
while (guess != n)
{
System.out.println("That is incorrect. Guess again");
System.out.print(">");
n = keyboard.nextInt();
}
System.out.println("Nice Job! You got it right!!!" );
}
}
Picture of the output