Prog70: Flip Again?
///Name: Ilana Levy
///Period: 5
///Program Name: Flip Again?
///File Name: flipAgain.java
///Date Finished: 9/22/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 = 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") );
}
}
//Yes, because with the do-while loop, no initial string value is necessary.