Created
November 17, 2016 03:43
-
-
Save netmask/005f05767e64be181696fb8ee554daa3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
public class Matriculas { | |
public static void main(String[] args) { | |
Scanner scanner = new Scanner(System.in); | |
HashMap<String, List<Double>> matriculas = new HashMap<String, List<Double>>(); | |
Double promedioGlobal = 0.0d; | |
System.out.println("Cuantos alumnos tiene el grupo"); | |
Integer numeroAlumnos = scanner.nextInt(); | |
for (int i = 1; i <= numeroAlumnos ; i++) { | |
System.out.println("Marticula alumno "+ i); | |
String matricula = scanner.next(); | |
while (matriculas.containsKey(matricula)){ | |
System.out.println("Matricula repetida!"); | |
matricula = scanner.next(); | |
} | |
List<Double> calificaciones = new ArrayList<Double>(); | |
for (int j = 1; j <= 3; j++) { | |
System.out.println("Calificacion "+ j); | |
calificaciones.add(scanner.nextDouble()); | |
} | |
matriculas.put(matricula, calificaciones); | |
} | |
for(Map.Entry<String, List<Double>> matricula : matriculas.entrySet()){ | |
Double promedioPersonal = 0d; | |
for(Double calificacion : matricula.getValue()){ | |
promedioPersonal += calificacion; | |
promedioGlobal += calificacion; | |
} | |
System.out.println("Promedio de la matricula"+ matricula.getKey() +" es "+ (promedioPersonal / 3)); | |
} | |
System.out.println("El Promedio Gobal es "+ (promedioGlobal / numeroAlumnos)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment