Hi i need to change the random numbers in my output to random 'b''s that take up 2/3 of the array and random 'x''s to take up 1/3. Ive been at it for a few days and still have no clue on what to do. Heres my coding and output:
import java.util.Random;
public class Board
{
/**
* Create Board
*/
final int rowWidth = 10;
final int colHeight = 10;
int [][] board = new int [rowWidth][colHeight];
Random rand = new Random();
/**
* Display the board
*/
public void getBoard()
{
for (int row = 0; row < board.length; row++)
{
for (int col = 0; col < board[row].length; col++)
{
board[row][col] = rand.nextInt(10);
}
}
//display output
for(int i = 0; i < board.length; i++) {
for(int j = 0; j < board[i].length; j++) {
System.out.print(board[i][j] + " ");
//System.out.println();
}
System.out.println();
}
}
}
Output:
2 0 1 0 7 8 7 7 7 4
2 3 0 1 5 9 9 3 6 1
9 8 7 8 1 1 2 7 6 4
5 8 0 1 8 1 3 3 8 9
2 5 5 2 9 6 9 3 6 4
3 9 2 5 5 1 2 6 3 0
2 9 0 3 0 0 9 4 9 1
8 4 0 2 8 6 0 4 8 6
4 5 6 1 9 0 8 2 8 8
1 2 2 0 5 9 1 6 2 4
thanks