Prog 66: Hi Lo with Limited Tries

///Name: Ilana Levy
///Period: 5
///Program Name: Hi Lo with Limited Tries
///File Name: limitedHiLo.java
///Date Finished: 9/21/2015

import java.util.Scanner;
import java.util.Random;

public class limitedHiLo
{
        public static void main( String[] args )
        {
                Scanner keyboard = new Scanner( System.in );
                Random r = new Random();
                
                int guess, number = 1 + r.nextInt(100), tries = 2;
                
                System.out.println( "I'm thinking of a number between 1-100. You have 7 guesses.\nFirst Guess: " );
                guess = keyboard.nextInt();
                
                while ( guess != number && tries < 7 )
                {
                        if (guess < number )
                        {   
                            System.out.println( "Sorry, you are too low.\nGuess #" + tries + ":" );
                            guess = keyboard.nextInt();
                            tries++;
                        }
                        else if ( guess > number )
                        {
                            System.out.println( "Sorry, that guess is too high.\nGuess #" + tries + ":" );
                            guess = keyboard.nextInt();
                            tries++;
                        }
                }
                
                if ( tries < 7 )
                    System.out.println( "You guessed it! What are the odds?!?" );
                else if ( tries == 7 )
                    System.out.println( "Sorry, you didn't guess it in 7 tries. You lose." );
        }
}