// Use this editor to write, compile and run your Java code online import java.util.Scanner; class HelloWorld { public static void main(String[] args) { Scanner sn =new Scanner(System.in); int totalM= 0; int totalMod= 0; int totalH= 0; int totalF = 0; int totalper,i; String genero, modelo, futbol;
System.out.print("Cuantas personas deseas ingresar: ");
totalper=sn.nextInt(); for ( i = 0; i < totalper; i++) { System.out.println("A continuacion digite si es hombre o mujer"); System.out.println("Persona " + (i + 1) + ": "); genero=sn.next(); if (genero.equalsIgnoreCase("mujer")) { totalM++; System.out.print("Es modelo: (si/no): "); modelo=sn.next(); if (modelo.equalsIgnoreCase("si")) { totalMod++; }} else if (genero.equalsIgnoreCase("hombre")) { totalH++; System.out.print("Es futbolista:(si/no): "); futbol=sn.next(); if (futbol.equalsIgnoreCase("si")) { totalF++; } } else { System.out.println("Genero no reconocido. Por favor, ingresa mujer o hombre"); i--; } } System.out.println("\nResultados:"); System.out.println("Total de mujeres: " +totalM); System.out.println("Total de modelos: " +totalMod); System.out.println("Total de hombres: " +totalH); System.out.println("Total de futbolistas: " +totalF); } }