1
Good morning friends, I’m trying to implement this code but it’s giving error.
public int totalFaltasAluno(int matricula) {
int totalFaltas = 0;
for(Integer item : faltas){
if(item == matricula){
totalFaltas++;
}
}
return totalFaltas;
public boolean verificarReprovacaoPorFalta(int matricula) {
int presenca = 90 - totalFaltas;//90 são os dias de aulas
if (presenca < (90-0.75-90));// presenca menor que 75% de 90 dias de aulas
return true;
}
error:
Exception in thread "main" java.lang.Error: Unresolved compilation
problem:
totalFaltas cannot be resolved to a variable
at Gerenciar_frequencia.Pauta.verificarReprovacaoPorFalta(Pauta.java:45)
Main class is like this.
if (pauta.verificarReprovacaoPorFalta(aluno.getMatricula())){
System.out.println(" Presença: reprovado");
}
else{
System.out.println(" Presença: normal");
}
thanks for the reply, I added a part of the main class, I could not implement , the return is always stay "true".
– Bruno
to stay true always the presence is being less than (90-0.75-90) = -0.75..
– Hiago Souza
I’ve edited the algorithm, so if you want 75% of 90 it’s only 90 by 0.75 and not subtract. To know how many % the amount X of fouls represents in 90 it is necessary to make use of the rule of 3. I edited the algorithm.
– Hiago Souza
Hiago Souza, is returning true always, but thank you.
– Bruno
What value has in totalFaltas?
– Hiago Souza
Now that I noticed the name of the method I updated the routines..
– Hiago Souza
I have 3 total fouls , are 27, 6, 0
– Bruno
Try again, I edited the script... I got confused here
– Hiago Souza
thanks again Hiago, but is returning true again.
– Bruno
Let’s go continue this discussion in chat.
– Bruno