Hi,
Do any of you have an idea why the validation fails in my case? I tried to test it in a many different ways and every time I get the correct output but last condition still fails :(
package pl.codegym.task.task19.task1919;
/*
Obliczanie wynagrodzeń
*/
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.*;
public class Solution {
public static void main(String[] args) throws IOException {
String fileName = args[0];
FileReader fr = new FileReader(fileName);
BufferedReader fileReader = new BufferedReader(fr);
Map<String, Double> map = new TreeMap<>();
String line = null;
while ((line = fileReader.readLine()) != null) {
String[] splittedLine = line.split(" ");
if (!map.containsKey(splittedLine[0])) {
map.put(splittedLine[0], Double.parseDouble(splittedLine[1]));
} else if (map.containsKey(splittedLine[0])) {
map.put(splittedLine[0], map.get(splittedLine[0]) + Double.parseDouble(splittedLine[1]));
}
}
fr.close();
fileReader.close();
for (Map.Entry<String, Double> entry : map.entrySet()) {
System.out.println(entry);
}
}
}