Assignemnt #55 A Number Guessing Game
Code
///Name: Morgan Kaplan
///Period: 5
///Project Name: A Number Guessing Game
///File Name: NGG.java
import java.util.Random;
import java.util.Scanner;
public class NGG
{
public static void main( String[] args )
{
Scanner momo= new Scanner(System.in);
Random r =new Random();
int choice=1+ r.nextInt(10), guess;
System.out.println ( " What number am I thinking of 1-10?" );
guess=momo.nextInt();
if ( guess==choice )
{
System.out.println( " wow youre right." );
}
else
{
System.out.println( "Wrong it was " + choice + "." );
}
}
}
Picture of Output