Assignemnt #70 and FlipAgain

Code

  /// name: Leila Ordukhani
  /// period: 6
  /// program name: Sixtieth Program
  /// file name: FlipAgain.java
  /// date finished: 12/10/15
  
      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 = 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") );
    	}
    }
    // the program works even if again isnt given a value before the do-while loop; this is because the loop doesn't need to meet the parameters before running once
  

Picture of the output

Assignment 70