Assignment #55

Code

    /// Name: Jonathan Stine
    /// Period: 5
    /// Program Name: A Number-Guessing Game
    /// File Name: Game.java
    /// Date Finished: 1/19/16
    
    import java.util.Scanner;
    
    import java.util.Random;
    
    public class Game {
        
        public static void main( String[] args ) {
            
            Scanner keyboard = new Scanner(System.in);
            
            Random r = new Random();
            
            int guess, number;
            number = 1 + r.nextInt(10);
            
            System.out.println( "Get ready to play THE WORST NUMBER GUESSING GAME EVERRR!" );
            System.out.println();
            
            System.out.print( "I'm thinking of a number from 1-10. Try to guess it: " );
            guess = keyboard.nextInt();
            System.out.println();
            
            if ( guess == number ) {
                System.out.println( "Impressive. You actually guessed it that it was " + number + "!" );
            }
            
            if ( guess > number ) {
                System.out.println( "Lame. It was " + number + "!" );
            }
            
            if ( guess < number ) {
                System.out.println( "Loser. It was " + number + "!" );
            }
            
        }
    }

    
 
    

Code Output