Assignemnt #55: Random Number Guessing Game
Code
/// Name: Sean Harrison
/// Period: 7
/// Program name: Random Number Guessing Game
/// File Name: GoodNGG.java
/// Date Finished: 11/10/2015
import java.util.Scanner;
import java.util.Random;
public class GoodNGG
{
static public void main( String [] args )
{
Scanner keyboard = new Scanner(System.in);
Random r = new Random();
int RandomNumber, guess;
RandomNumber = 1 + r.nextInt(10);
System.out.println( "We're going to play a game now involving the prediction of the whole number between 1-10 that I so desire " );
System.out.println( "You only have one shot, choose carefully from 1 through 10 " );
guess = keyboard.nextInt();
if (RandomNumber == guess)
{
System.out.println( "Nice job, how'd you know that the number was " + RandomNumber );
}
if (RandomNumber != guess)
{
System.out.println( "Hahaha, you're extremely horrible at this, the correct number was " + RandomNumber );
}
else
{
System.out.println( "Error." );
}
}
}
Picture of the output