Assignemnt #66 and Hi-Lo with limit

Code

    
    ///name: nick cerdan
    ///period: 6
    ///program name:Hi-Lo w/ limit
    ///file name: HiLoLimit.java
    ///date finished: 10/22/15
    
    import java.util.Random;
    import java.util.Scanner;
    
    public class HiLoLimit
    {
        public static void main(String[] args)
        {
            Random r = new Random();
            Scanner keyboard = new Scanner(System.in);
            
            int snumber, guess, n;
            
            snumber = 1 + r.nextInt(100);
            n = 0;
            System.out.println("I'm thinking of a number between 1-100. You have 7 guesses. Good luck!");
            System.out.print("Guess #" + (n+1) + ": ");
            guess = keyboard.nextInt();
            System.out.println("");
            n++;
            
            while (guess != snumber && n < 7)
            {
                if (guess > snumber)
                {
                    System.out.println("You were a little high.");
                    System.out.print("Guess #" + (n+1) + ": ");
                    guess = keyboard.nextInt();
                    System.out.println("");
                    n++;
                }
                
                else if (guess < snumber)
                {
                    System.out.println("You were a little low.");
                    System.out.print("Guess #" + (n+1) + ": ");
                    guess = keyboard.nextInt();
                    System.out.println("");
                    n++;
                }
            }
            
            if (guess == snumber)
            {
                System.out.println("You got it!");
            }
            
            else if (n >= 7)
            {
                System.out.println("Sorry you ran out of tries. you lose.");
            }
        }
    }
    
    Assignment 65