Assignemnt #55 and A Number Guessing Game
Code
///Name: Dakota Donahue
///Period: 5
///Project Name: A Number Guessing Game
///File Name: NumberGuessing.java
///Date: 12/4/2015
import java.util.Scanner;
import java.util.Random;
public class NumberGuessing
{
public static void main ( String[] args )
{
Scanner keyboard = new Scanner(System.in);
Random r = new Random();
int rN = 1 + r.nextInt(10);
int guess;
System.out.println( " I'm thinking of a number from 1 to 10 " );
System.out.print( " Your guess: " );
guess = keyboard.nextInt();
if ( guess == rN )
{
System.out.println( " That's right! my secret number was " + rN );
}
else
{
System.out.println( " Sorry, but I was really thinking of " +rN );
}
}
}