import java.util.ArrayList;
import java.util.HashMap;
public class WeightProgram {
private HashMap<String,ArrayList<Double>> weightLogs = new HashMap<String,ArrayList<Double>>();
public WeightProgram () {
ArrayList<Double> log1 = new ArrayList<Double>();
ArrayList<Double> log2 = new ArrayList<Double>();
ArrayList<Double> log3 = new ArrayList<Double>();
weightLogs.put("OlaNor", log1);
weightLogs.put("PerSpe", log2);
weightLogs.put("EspAsk", log3);
}
public String biggestLooser() {
String looserName = "None";
double highestLoss = Double.NEGATIVE_INFINITY;
double initialWeight;
double currentWeight;
double prosentageWeightLoss;
for (String username : weightLogs.keySet()) {
ArrayList<Double> log = weightLogs.get(username);
initialWeight = log.get(0);
currentWeight = log.get(log.size()-1);
prosentageWeightLoss = 100 - ((100/initialWeight)*currentWeight);
if(prosentageWeightLoss > highestLoss) {
looserName = username;
highestLoss = prosentageWeightLoss;
}
}
return looserName;
}
} |