0
Good afternoon, I need to compare two files .txt
and check that each character is equal to the other file and store which characters are equal... Type a template
an archive prova.txt
has the following content:
1;VVFF
2;VFVF
3;FFFV
The template has the contents:
1;VVFF
2;FFVV
3;FFFF
Make a comparison and add up how many answers they got right
int pontuacao = 0;
Scanner sc = new Scanner(System.in);
String gabaritoVetor[] = new String[3];
String notaVetor[] = new String[3];
for (int c = 0; c < gabaritoVetor.length; c++) {
gabaritoVetor[c] = leitura; //recebe os dados do prova.txt
}
for (int i = 0; i < notaVetor.length; i++) {
notaVetor[i] = leitura2; //recebe os dados do gabarito.txt
if (notaVetor[i].equals(gabaritoVetor[i])) {
pontuacao++;
}
}
System.out.println("\nPontuação: " + pontuacao);
I tested with the same files worked, when I modified gave Pontuação = 0
If the files are equal shows Pontuação = 3
Any idea???
I think he’s comparing every line in the file, not every character.
– Claudio Lopes