Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.HashMap;
- import java.util.Scanner;
- public class Temperaturi {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- HashMap <String, String> hashMap = new HashMap<>();
- for (int i=0;i<n;i++)
- {
- String [] vlez = scanner.nextLine().split(" ");
- String temperatura = vlez[3];
- String grad= vlez[0];
- String vremenskiInterval = vlez[1].concat(" ").concat(vlez[2]).concat(" ").concat(temperatura);
- if (hashMap.containsKey(grad))
- {
- if (!hashMap.get(grad).contains(vremenskiInterval))
- hashMap.put(grad, hashMap.get(grad) + " " + vremenskiInterval);
- }
- else
- hashMap.put(grad,vremenskiInterval);
- }
- String cityToCheck = scanner.nextLine();
- double maxValue = Double.parseDouble(hashMap.get(cityToCheck).split(" ")[2]);
- String vInterval;
- for (String keys : hashMap.keySet()) {
- if (keys.equals(cityToCheck)) {
- for (String values : hashMap.get(keys).split(" ")) {
- try {
- if (maxValue < Double.parseDouble(values)) {
- maxValue = Double.parseDouble(values);
- }
- } catch (NumberFormatException e) {
- }
- }
- }
- }
- System.out.println(maxValue);
- }
- }
- /*
- 6
- Skopje 13:00 15:30 25.6
- Prilep 12:00 18:00 23.0
- Bitola 16:00 18:30 22.3
- Prilep 17:00 20:00 17.0
- Prilep 18:00 20:30 18.2
- Prilep 19:00 22:00 25.9
- Prilep
- 25.9*/
Advertisement
Add Comment
Please, Sign In to add comment