Advertisement
Telinc1

World Selector

Apr 21st, 2013
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.73 KB | None | 0 0
  1. package telinc.worldselector;
  2.  
  3. import java.util.Random;
  4.  
  5. public class WorldSelector {
  6.     private static Random rand = new Random();
  7.     private static int zeroes = 0;
  8.     private static int ones = 0;
  9.  
  10.     public static void main(String[] args) {
  11.         for(int i = 0; i < 30; i++){
  12.             generatePairs();
  13.         }
  14.  
  15.         System.out.println("Generated " + zeroes + " zeroes");
  16.         System.out.println("Generated " + ones + " ones");
  17.     }
  18.  
  19.     private static void generatePairs() {
  20.         for(int i = 0; i < 30; i++){
  21.             int randomNumber = rand.nextInt(2);
  22.  
  23.             if(randomNumber == 0){
  24.                 zeroes++;
  25.             }else{
  26.                 ones++;
  27.             }
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement