-2
I was developing a Java application that basically creates a 4 x 4 matrix, which has to count and write how many values greater than 10 it has, until I was able to do this, but the text that asks the user to type two values (the one in the row and the one in the column) always appears duplicated, I’ve tried to do many things, but it didn’t help much.
Program code:
import java.util.Scanner;
public class main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int contagem = 0;
int matriz[][] = new int [4][4];
for (int linha = 0; linha < 4; linha++) {
for (int coluna = 0; coluna < 4; coluna++) {
System.out.println("\nInsira dois numeros, um para a coluna e outro para a linha = ");
matriz[linha][coluna] = sc.nextInt();
if (matriz[linha][coluna] > 10) {
contagem++;
}
}
}
System.out.println("Na matriz existem: " + contagem + " numeros maiores que 10");
}
}
Don’t greet, don’t thank and don’t write Solved in the title. To mark a question as solved mark an answer as accepted. See: How and why to accept an answer and What kind of behavior is expected from users?
– Augusto Vasques