grodek118

Heads or tails

Nov 3rd, 2022 (edited)
699
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.47 KB | None | 0 0
  1. import java.util.Random;
  2.  
  3. public class Main {
  4.  
  5.     public static void main(String[] args) {
  6.  
  7.         int toss;
  8.  
  9.         Random randomNumber = new Random();
  10.  
  11.         for (int i = 0; i <= 10; i++)
  12.         {
  13.             toss = randomNumber.nextInt(2);
  14.  
  15.             if (toss == 1)
  16.             {
  17.                 System.out.println("Heads");
  18.             }
  19.             else
  20.             {
  21.                 System.out.println("Tails");
  22.             }
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment