
Introducir n alumnos y contar cuantos son hombres y cuantas mujeres son el el grupo
Publicado por David Cristian (1 intervención) el 09/03/2017 04:06:25
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package proyecto11_unidad1;
import java.util.Scanner;
public class Proyecto11_Unidad1 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int alum,x=0,hom=0,muj=0,opc=0;
System.out.println("Cuantos Alumnos desea ingresar: ");
alum=sc.nextInt();
while(x<alum){
System.out.println("¿Eres Hombre o mujer?");
System.out.println("1: Hombre"
+ "\n2: Mujer"
+ "\nElige una opcion");
opc=sc.nextInt();
switch(opc){
case 1:
System.out.println("Hombre");
hom=hom+1;
x++;
break;
case 2:
System.out.println("Mujer");
muj=muj+1;
x++;
break;
default:
System.out.println("Esa opcion no existe");
alum=alum-1;
x--;
}
}
System.out.println("Total de Hombres en el salon: "+hom);
System.out.println("Total de Mujeres en el salon: "+muj);
}
}
Valora esta pregunta


0