Assignemnt #66 and Hi-Lo with Limited Tries

Code

///Name: Ben Borglin
///Period: 6
///Program name: Hi-Lo with limited tries
///file name: HiLoLimit.java
///Date Finsihed: 10/21/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 tries;
        tries = 0;
        
        int number = 1 + r.nextInt(100);
        
        System.out.println("I am thinking of a number between 1-100.");
        System.out.print("Try and guess it: ");
        int guess = keyboard.nextInt();
        
        while (guess != number && tries < 7)
        {
            if (guess > number)
            {
                System.out.println("Sorry, you are a little high.");
                System.out.println(" ");
                System.out.println("I am thinking of a number between 1-100.");
                System.out.println(" ");
                guess = keyboard.nextInt();
                tries++;
            }
            else if (guess < number)
            {
                System.out.println("Sorry, you are a little low.");
                System.out.println(" ");
                System.out.println("I am thinking of a number between 1-100.");
                System.out.println(" ");
                guess = keyboard.nextInt();
                tries++;
            }
        }
        if ( guess == number )
            System.out.println("Good job guessing! You got it in " + tries + "!!!");
        else if ( guess >= 7 )
            System.out.println("Sorry your ran out of tries.");
    }
}
        
 
    

Picture of the output

Assignment 66