import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class WeightProgram {
private Map<String,List<Double>> weightLogs = new HashMap<String,List<Double>>();
public WeightProgram () {
initializeLogs(weightLogs);
}
public String biggestLooser() {
String looserName = null;
double highestLoss = Double.NEGATIVE_INFINITY;
for (Map.Entry<String, List<Double>> entry : weightLogs.entrySet()) {
List<Double> log = entry.getValue();
double initialWeight = log.get(0);
double currentWeight = log.get(log.size()-1);
double prosentageWeightLoss = 100 - ((100/initialWeight)*currentWeight);
if(prosentageWeightLoss > highestLoss) {
looserName = entry.getKey();
highestLoss = prosentageWeightLoss;
}
}
return looserName;
}
private void initializeLogs(Map<String,List<Double>> map) {
List<Double> log1 = new ArrayList<Double>();
List<Double> log2 = new ArrayList<Double>();
List<Double> log3 = new ArrayList<Double>();
log1.add(95.0);
log1.add(93.1);
log1.add(87.9);
log2.add(123.0);
log2.add(119.1);
log2.add(115.9);
log3.add(102.0);
log3.add(100.1);
log3.add(98.3);
weightLogs.put("OlaNor", log1);
weightLogs.put("PerSpe", log2);
weightLogs.put("EspAsk", log3);
}
}