I'm having difficulty here so the user can type how many letters each of them wants to be drawn. Example as in the code below shows the letters char[] letras = new char[]{'S', 'C', 'M', 'A','L'};
. These letters are drawn in the array, but I want to make the user type how many S
, how C
, how M
, and so on. My code is the one below ..
public class exemplo {
public static void main(String[] args) {
int tamanho = 4;
char[] letras = new char[]{'S', 'C', 'M', 'A','L'};
char matrix [][] = new char[tamanho][tamanho];
Random random = new Random();
for (int i = 0; i < tamanho; i++) {
for (int j = 0; j < tamanho; j++) {
matrix[i][j] = letras[random.nextInt(letras.length)];
}
}
for (int i = 0; i < tamanho; i++) {
for (int j = 0; j < tamanho; j++) {
System.out.print("|" + matrix[i][j] + "|");
}
System.out.println("");
}
}
}