3
I am having difficulty here to be able to type how many letters of each one it 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 matrix, but I want to make the user type how many S
, how many C
, how many M
and so on. My code is this 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("");
}
}
}
What would happen if the sum of S, C, M, A and L given by the user is different from 16?
– Victor Stafusa
well thought out, would make a big mistake
– Joycinha
what you would recommend me to do?
– Joycinha
It depends. What do you want to do with it? Why do you want to do this?
– Victor Stafusa
to make an agent, distribute letters in the matrix for the agent to search for the dirt and clean...
– Joycinha