Java program that lets the user guess whether the flip of a coin results in heads or tails. The program randomly generates an integer 0 or 1, which represents head or tail. The program prompts the user to enter a guess and reports whether the guess is correct or incorrect.

Liang Introduction to Java Programming exercise 3.14 solution
Program sample run

Click here to see other solutions to Introduction to Java Programming.