public class FlipAgain
public static void main( String args )
Scanner keyboard = new Scanner(System.in);
Random rng = new Random();
int flip = rng.nextInt(2);
if ( flip == 1 )
coin = "HEADS";
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 still works after making the small changes and removing the first line of code because having the first lines and a while-statment.
is the same as just having a do while.
Picture of the output