Assignemnt #70: Flip Again?

Code

    /// Name: Kelsey Lieberman
    /// Period 5
    /// 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;

		do
		{
			int flip = 1 + rng.nextInt(1001);
			String coin;

			if ( flip <= 500 )
				coin = "HEADS";
			else if (flip > 500 && flip <=1000)
				coin = "TAILS";
            else
                coin = "SIDE";

			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") );
	}
}
///yes, it still works because the variable is initialized in the "do" part of the program before the while loop is put in effect.
    

Picture of the output

Assignment 70