hello everyone,.
here is my bingo program,. but it happened that i had a problem with it its because it generates same numbers i mean sometimes i get two 8 numbers for letter B and sometimes i get three of them same in I or in any of my bingo letters,. could someone point me to the right direction,. on how can i eliminate those same numbers and change them w/ a new one and i also tried using while(Bnum[ctr]==Bnum[ctr+1]) and what i get ArrayIndexOutOfBoundsException
so far this is my working bingo card,. but generating same numbers,. please help
CODE
public class Bingo2
{
public static void main (String [] args)
{
int Bnum[] = new int[5];
int Inum[] = new int[5];
int Nnum[] = new int[5];
int Gnum[] = new int[5];
int Onum[] = new int[5];
int Bingonum[][] = new int[5][5];
int ctr, ctr1,fixnum = 0;
for(ctr = 0; ctr <Bnum.length; ctr++)
{
Bnum[ctr] = (int) (Math.random() * 15 + 1);
}
for(ctr = 0; ctr <Inum.length; ctr++)
{
Inum[ctr] =(int) (Math.random() * 15 + 16);
}
for(ctr = 0; ctr <Nnum.length; ctr++)
{
Nnum[ctr] =(int) (Math.random() * 15 + 31);
}
for(ctr = 0; ctr <Gnum.length; ctr++)
{
Gnum[ctr] =(int) (Math.random() * 15 + 45);
}
for(ctr = 0; ctr <Onum.length; ctr++)
{
Onum[ctr] =(int) (Math.random() * 15 + 61);
}
System.out.print(" B I N G O");
for(ctr = 0; ctr < Bingonum.length; ctr++)
{
System.out.print("\n");
for(ctr1 = 0; ctr1 < Bingonum.length; ctr1++)
{
if (ctr1 >= 4)
{
System.out.print(" " + Onum[ctr]);
}
else if(ctr1 >= 3)
{
System.out.print(" " + Gnum[ctr]);
}
else if (ctr1 >= 2)
{
if(ctr == 2)
{
System.out.print(" FR " );
}
else
{
System.out.print(" " + Nnum[ctr]);
}
}
else if(ctr1 >= 1)
{
System.out.print(" " + Inum[ctr]);
}
else
{
System.out.print(" " + Bnum[ctr]);
}
}
}
}
}
here is some of examples,. of same numbers generated
untitled.bmp ( 60.17k )
Number of downloads: 7