Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.HashMap;
- import java.util.Scanner;
- class Merenja{
- double sum;
- int counter;
- public Merenja(double n){
- sum=n;
- counter=1;
- }
- }
- public class Main {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- int brMerenja = Integer.parseInt(in.nextLine());
- HashMap<String, Merenja> hashMap = new HashMap<>();
- for (int i=0;i<brMerenja;i++){
- String [] niza = in.nextLine().split(" ");
- String opstina = niza[0];
- double temperatura = Double.parseDouble(niza[1].replace(',','.'));
- if (hashMap.containsKey(opstina)){
- hashMap.get(opstina).counter++;
- hashMap.get(opstina).sum+=temperatura;
- }
- else {
- hashMap.put(opstina, new Merenja(temperatura));
- }
- }
- String grad = in.next();
- System.out.println(hashMap.get(grad).sum/hashMap.get(grad).counter);
- }
- }
- /*
- 5
- Karposh 5,2
- Chair 3,11
- Centar 2,23
- Karposh 1,7
- Karposh 2,67
- Karposh
- 3.19*/
Advertisement
Add Comment
Please, Sign In to add comment