Assignment #66 and Hi-Lo with Limited Tries

Code

    /// Name: Lauren Baird
    /// Period: 7
    /// Program Name: Hi-Lo with Limited Tries
    /// File Name: LimitedTries.java
    /// Date Finished: 11/5/2015
    
    import java.util.Random;
    import java.util.Scanner;
        
    public class LimitedTries
    {
        public static void main( String[] args )
        {
            Random r = new Random();
            Scanner keyboard = new Scanner(System.in);
                
            int number = 1 + r.nextInt(100);
            int t = 0;
            int max = 7;
                
            System.out.println();
            
            System.out.println( "I'm thinking of a number between 1 and 100. Try to guess it." );
            System.out.print( "Guess #" + (t+1) + ": " );
            int guess = keyboard.nextInt();
            t++;
                
            while ( guess != number && t < max )
            {
                
                if ( guess <= number )
                {
                    
                    System.out.println( "Sorry, you are too low." );
                    System.out.print( "Guess #" + (t+1) + ": " );
                    guess = keyboard.nextInt();
                    t++;
                }
                
                if ( guess >= number )
                {
                    
                    System.out.println( "Sorry, you are too high." );
                    System.out.print( "Guess #" + (t+1) + ": " );
                    guess = keyboard.nextInt();
                    t++;
                }
                
            }
            
            System.out.println();
            
            if ( guess == number )
                System.out.println( "You guessed it! What are the odds?! " );
            else if ( t >= max )
                System.out.println( "Sorry, you didn't guess it in 7 tries. You lose." );
            
        }
    }    
    

Picture of the output

Assignment #66