Assignment 72 and AgainNG

Code

///Matthew Hughs
///Period 5
///AgainNG
///AgainNG.java
///1/11/2016

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

class AgainNG
{
    public static void main (String [] args)
    {
        Scanner keyboard = new Scanner(System.in);
        Random rng = new Random();
        
        int ans, x , tries;
        x = 1 + rng.nextInt(10);
        tries = 0;
        System.out.println("I have chosen a number between 1 and 10, make a guess.");
        do
        {
            System.out.print("Your guess : ");
            ans = keyboard.nextInt();
            tries++;
            if (x != ans)
            {
                System.out.println("Wrong, try again");
            }
        } while (x != ans);
        
        System.out.println("Congrats you guess " + x + " and it only took you " + tries + " tries.");
    }
}
    

Picture of the output

AgainNG