import java.util.*;
class Ideone {
public static void main
(String[] args
) { Scanner in
= new Scanner
(System.
in); mapa.put("45 - Jose" , 0); //A "Key" deve ser o numero do Candidato,
mapa.put("13 - Maria" , 0); // e o "Value" o contador que vai
mapa.put("20 - Pedro" , 0); // contabilizar os votos, porem nao sei
mapa.put("50 - Carol" , 0); // como criar o contador aqui.
for (Map.
Entry<String, Integer
> conteudo
: mapa.
entrySet()) { System.
out.
println(conteudo.
getKey()); System.
out.
printf("Votos = %d \n", conteudo.
getValue()); }
do {
System.
out.
println("\nEm que candidato deseja votar? "); if (mapa.containsKey(key)) {
mapa.put(key, mapa.get(key) + 1);
System.
out.
printf("\nCandidato: %s \nVotos = %d \n", key, mapa.
get(key
)); } else {
System.
err.
printf("\nCandidato %s nao encontrado.\n", key
); }
System.
out.
println("\nDeseja continuar: (s/n)"); continuar = in.nextLine();
} while ("s".equalsIgnoreCase(continuar));
}
}
aW1wb3J0IGphdmEudXRpbC4qOwpjbGFzcyBJZGVvbmUgewoJcHVibGljIHN0YXRpYyB2b2lkIG1haW4oU3RyaW5nW10gYXJncykgewoJICAgIFNjYW5uZXIgaW4gPSBuZXcgU2Nhbm5lciAoU3lzdGVtLmluKTsKCSAgICBNYXA8U3RyaW5nLEludGVnZXI+IG1hcGEgPSBuZXcgSGFzaE1hcDxTdHJpbmcsSW50ZWdlcj4oKTsKCSAgICBtYXBhLnB1dCgiNDUgLSBKb3NlIiAgLCAwKTsgLy9BICJLZXkiIGRldmUgc2VyIG8gbnVtZXJvIGRvIENhbmRpZGF0bywgICAgICAgIAoJICAgIG1hcGEucHV0KCIxMyAtIE1hcmlhIiAsIDApOyAvLyBlICBvICJWYWx1ZSIgbyBjb250YWRvciAgcXVlIHZhaSAKCSAgICBtYXBhLnB1dCgiMjAgLSBQZWRybyIgLCAwKTsgLy8gY29udGFiaWxpemFyIG9zIHZvdG9zLCAgcG9yZW0gbmFvIHNlaQoJICAgIG1hcGEucHV0KCI1MCAtIENhcm9sIiAsIDApOyAvL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