SHARE
TWEET

Pr10_for_edit

mirozspace Apr 25th, 2019 125 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.HashMap;
  2. import java.util.Map;
  3. import java.util.Scanner;
  4.  
  5. public class Pr10SoftUniExamResults {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         Map<String, Map<String, Integer>> commonInformation = new HashMap<>();
  10.         Map<String, Integer> languageAndPeople = new HashMap<>();
  11.         Map<String, Integer> temp;
  12.  
  13.         String line = scanner.nextLine();
  14.         while (!line.equals("exam finished")) {
  15.             String[] arrLine = line.split("-");
  16.             String name = arrLine[0];
  17.             String language = arrLine[1];
  18.  
  19.             int addressOfMap;
  20.             if (!language.equals("banned")) {
  21.                 int points = Integer.parseInt(arrLine[2]);
  22.                 commonInformation.putIfAbsent(language, new HashMap<>());
  23.                 temp = commonInformation.get(language);
  24.                 temp.putIfAbsent(name, points);
  25.                 if (points> temp.get(name)){
  26.                     temp.put(name, temp.get(name) + points);
  27.                 }
  28.                 if (!languageAndPeople.containsKey(language)) {
  29.                     languageAndPeople.put(language, 1);
  30.                 } else {
  31.                     languageAndPeople.put(language, languageAndPeople.get(language) + 1);
  32.                 }
  33.             } else {
  34.                 temp = commonInformation.get(language);
  35.                 temp.remove(name);
  36.             }
  37.             line = scanner.nextLine();
  38.         }
  39.         System.out.println();
  40.     }
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top