random number generator for the new powerball

1

Click here to load reader

Upload: noeldtan

Post on 10-Apr-2015

1.300 views

Category:

Documents


2 download

DESCRIPTION

Beginning on January 2009, the new PowerBall will have 59 whiteballs and 39 powerballs to choose from.This simple java program will generate 5 random numbers from 1-59 and 1 number from 1-39.GOOD LUCK!

TRANSCRIPT

Page 1: RANDOM NUMBER GENERATOR FOR THE NEW POWERBALL

PowerBallimport java.util.*;

class PowerBall {public static void main(String[] args) {System.out.println();for(int i=0; i< 30; i++) {boolean[] taken = new boolean[60];int count = 0;Random r = new Random();int[] uniqueRNums = new int[5];

while(count < 5){ int rNum = (r.nextInt(59) + 1);if(!taken[rNum]){taken[rNum] = true;uniqueRNums[count] = rNum;count++;System.out.print(rNum + " ");}}

System.out.println(" " + (r.nextInt(39) + 1) + "\n");

}}}

Page 1