Assignemnt #70 Flip Again?

Code

   
    /// Name: Jake Johnson
    /// Period: 7
    /// Program Name: FlipAgain
    /// File Name: FlipAgain.java
    /// Date Finished: 12/11/2015
    
import java.util.Random;
import java.util.Scanner;

public class FlipAgain
{
	public static void main( String[] args )
	{
		Scanner keyboard = new Scanner(System.in);
		Random rng = new Random();

		String again; //the program works now because it checks the condition after the loop instead of before it, meaning that it will do the loop until the condition is no longer met as apposed to doing the loop while the condition is met

		do
		{
			int flip = rng.nextInt(2);
			String coin;

			if ( flip == 1 )
				coin = "HEADS";
			else
				coin = "TAILS";

			System.out.println( "You flip a coin and it is... " + coin );

			System.out.print( "Would you like to flip again (y/n)? " );
			again = keyboard.next();
		}
        while ( again.equals("y") );
	}
}


    

Picture of the output

This should work