Advertisement
Sampywise

Coin Flip Program

Jul 9th, 2013
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.50 KB | None | 0 0
  1. import java.util.Random;
  2.  
  3. public class Lesson3 {
  4.     public static void main(String[] args) {
  5.         Random randy = new Random();
  6.         int first = randy.nextInt(10);
  7.         int second = randy.nextInt(10);
  8.         int result = addInts(first, second);
  9.         if(result < 2) {
  10.             System.out.println("Heads");
  11.         }
  12.         else {
  13.             System.out.println("Tails");
  14.         }
  15.     }
  16.     public static int addInts(int one, int two) {
  17.         int result = 2;
  18.         if(one > two) {
  19.             result = 1;
  20.         }
  21.         else {
  22.             result = 3;
  23.         }
  24.         return result;
  25.     }
  26.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement