viernes, 21 de noviembre de 2014

Modificar el programa para que calcule la media de todos los alumnos

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

package notas;
import java.util.Scanner;
/**
*
* @author juan
*/
public class Notas {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        int nota,media,numAlus,suma=0,numAsig=10;
        Scanner leer = new Scanner(System.in);
       
        do {
            System.out.println("Introduzca el número de alumnos");
            numAlus= leer.nextInt();
        } while (numAlus<=0);
       
        for (int i = 0; i < numAlus; i++) {
            suma=0;
            for (int j = 1; j <= numAsig; j++) {
                System.out.println("Introduzca la nota de la asignatura "+j);
                do {
                    nota=leer.nextInt();
                } while (nota<0 || nota >10);
                suma+=nota;
            }
            System.out.println("La media es: " + (suma/numAsig));
   
        }
      
    }
   
}

No hay comentarios: