Assignment 66 and Limited

Code

///Matthew Hughs
///Period 5
///Limited
///Limited.java
///1/4/2016


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

class Limited
{
    public static void main (String [] args)
    {
        Scanner keyboard = new Scanner(System.in);
        int guess;
        int total = 0;
        
        System.out.print("I have chosen a number between 1 and 100, guess what it is! ");
        guess = keyboard.nextInt();
        total++;
        
        Random r = new Random();
        
        int x = (1 + r.nextInt(100));
        
        while (x > guess && total < 7)
        {
            System.out.print("You are too low, try again ");
            guess = keyboard.nextInt();
            total++;
        }
        while  ( x < guess && total < 7)
        {
            System.out.print("You are too high, try again ");
            guess = keyboard.nextInt();
            total++;
        }
        if (guess == x )
        {
            System.out.println("Congragulations you guessed " + guess + " correctly.");
            System.out.println("It only took you " + total + " tries to get it.");
        }
         
        
            System.out.println("You tried to guess " + x + " a total of " + total + " times.");
        
        
    }
}
    

Picture of the output

Limited