Buscar en el sitio

Contacto

System Zone
Hebert Arteaga
Cajamarca

949686009

blinkof.hacker@hotmail.com

Hallar el numero de alumnos que desea saber su promedio de 4 notas utilizando while

28.06.2011 16:40

 package unc;

import java.util.Scanner;

public class ejerc3 {

/**

 * @param args

 */

public static void main(String[] args) {

Scanner leer =new Scanner(System.in);

double prom;

int n, a, b,c,d;

System.out.print("Ingrese el numero de alumnos que desea: ");

n=leer.nextInt();

for(int cont=1; cont<=n; cont++){

System.out.println("\n Alumno "+cont+": ");

System.out.print("Ingresa Nota 1: ");

a=leer.nextInt();

while(a<0 && a>20)System.out.print("Ingresa Nota 1: ");

System.out.print("Ingresa Nota 2: ");

b=leer.nextInt();

while(b<0||b>20);

System.out.print("Ingresa Nota 3: ");

c=leer.nextInt();

while(c<0||c>20);

System.out.print("Ingresa Nota 4: ");

d=leer.nextInt();

while(d<0||d>20);

prom=(a+b+c+d)/4; 

System.out.println("\t El promedio es "+prom);

}

 

}

 

}

 


cell: 949686009 Cajamarca