import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class EjercicioCalcularPromedio30alumnos {
public static void main(String[] args) throws IOException {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
int edad = 0;
int sumaedades = 0;
float promedio = 0;
for (int cantidad = 0; cantidad < 30; cantidad++) {
do {
System.out.println("Ingrese las notas de sus alumnos" + (cantidad + 1));
edad = Integer.parseInt (bf.readLine());
} while (!(edad > O));
sumaedades = sumaedades + edad;
promedio = sumaedades / cantidad;
}
System.out.println("su promedio es:" + promedio);
}
}
The code does not work, when it worked 5 minutes ago.
Ingrese la nota de sus alumnos1 3 Exception in thread "main" java.lang.ArithmeticException: / by zero at EjercicioCalcularPromedio30alumnos.main(EjercicioCalcularPromedio30alumnos.java:29) C:\Users\se_ba\AppData\Local\NetBeans\Cache.2\executor-snippets\run.xml:53: Java returned: 1 BUILD FAILED (total time: 2 seconds)