Approvals, reproaches and media of the room-Java

0

I need to receive 30 notes and return the number of approvals, disapprovals and the average room. I've tried the following:

public class notas { 
public static int aprovacoes;
public static int reprovacoes;
public static int recs;
public static double total;

public static void main(String []args){
    double notas[] = new double [30];

    Scanner input = new Scanner(System.in);
    System.out.print("Digite todas as notas: ");
    for(int i = 0; i < notas.length; i++){
        notas[i] = input.nextDouble();
    }
    System.out.println("numero de aprovados: "+aprovacoes);
    System.out.println("numero de reprovados: "+reprovacoes);
    System.out.println("numero de recs: "+recs);
    System.out.println("media da sala: "+(total/30));
}
    public static void resultadoSala(double [] notas){
        for(int i = 0; i < notas.length; i++){
            if(notas[i] >= 5){
                aprovacoes++;
            }
            else if(notas[i] <= 3){
                reprovacoes++;
            }
            else{
                recs++;
            }
        }
    }
    public static double mediaSala(double []notas){
        for(int i = 0; i < notas.length; i++){
            total += notas[i];  
        }
        return total;
    }

}

However, after compiling the code and inserting the notes, all outputs were equal to zero. What should I do?

    
asked by anonymous 13.05.2016 / 05:47

1 answer

1

The methods resultadoSala and mediaSala were missing:

public static void main(String []args){
    double notas[] = new double [30];

    Scanner input = new Scanner(System.in);
    System.out.print("Digite todas as notas: ");
    for(int i = 0; i < notas.length; i++){
        notas[i] = input.nextDouble();
    }

    resultadoSala(notas);
    mediaSala(notas);

    System.out.println("numero de aprovados: "+aprovacoes);
    System.out.println("numero de reprovados: "+reprovacoes);
    System.out.println("numero de recs: "+recs);
    System.out.println("media da sala: "+(total/30));
}
    
13.05.2016 / 10:17