Assignemnt #61 Keep Guessing
Code
///Name: Morgan Kaplan
///Period: 5
///Project Name: Keep Guessing
///File Name: KeepGuessing.java
import java.util.Scanner;
public class KeepGuessing
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
int n = 3, guess;
System.out.println("I have chosen a number between 1-10.");
System.out.print("What do you think the number is? ");
guess = keyboard.nextInt();
while ( guess != n )
{
System.out.println("INCORRECT Number. TRY AGAIN.");
System.out.print("ENTER YOUR Number: ");
guess = keyboard.nextInt();
}
System.out.println("That guess is right!");
}
}
Picture of Output