Advertisement
therrontelford

Heads or tails

Nov 12th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.44 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Chap3_14HeadsOrTails {
  3.  
  4.     public static void main(String[] args) {
  5.         Scanner grabber = new Scanner(System.in);
  6.         int randomNumber = (int)(Math.random() *2);
  7.        
  8.         System.out.println("Enter 0 for heads or 1 for tails");
  9.         int yourGuess = grabber.nextInt();
  10.        
  11.        
  12.         if (yourGuess == randomNumber){
  13.             System.out.println("You got it!!");
  14.         }
  15.         else
  16.             System.out.println("buzzer sound");
  17.  
  18.     }
  19.  
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement