Need Help with Java Urgent Plss


#1

Good night, my name is Gabriel and I am a student from Brazil. I am in senior year and I’ve decided to do my conclusive piece of work about pollution in Sao Paulo, I’ve been using a site called Numbeo and their pollution index, the problem is that they convert the numbers from the survey into a 0-100 range and they don’t provide the formula used in their site, only the java code. I honestly do not understand anything about Java, and not even if there is a way to reverse code and get the formula out of it, really hope someone can help.

Here is the code they provide on their website.

public void calculateIndex() {
//assumes air_quality and other entries from user are in the range [-2, 2], where -2 means perceived as very low, and +2 means very high
//PollutionDbEntry.IS_POLLUTION_AIR_QUALITY and similar are constant variables which are either -1 and 1; i.e. IS_POLLUTION_AIR_QUALITY = -1.0
//These constant variables in PollutionDbEntry class are 1 for values which represent pollutions and -1 for values which represent opposite (purity, cleanliness)
index = new PollutionIndex();
double overall = 0.0;
overall += 7 * getIndexPartPreCalc(PollutionDbEntry.IS_POLLUTION_AIR_QUALITY * air_quality);
overall += 2 * getIndexPartPreCalc(PollutionDbEntry.IS_POLLUTION_DRINKING_WATER_QUALITY_ACCESSIBILITY * drinking_water_quality_accessibility);
overall += 2 * getIndexPartPreCalc(PollutionDbEntry.IS_POLLUTION_WATER_POLLUTION * water_pollution);
overall += getIndexPartPreCalc(PollutionDbEntry.IS_POLLUTION_GARBAGE_DISPOSAL_SATISFACTION * garbage_disposal_satisfaction);
overall += getIndexPartPreCalc(PollutionDbEntry.IS_POLLUTION_CLEAN_AND_TIDY * clean_and_tidy);
overall += getIndexPartPreCalc(PollutionDbEntry.IS_POLLUTION_NOISE_AND_LIGHT_POLLUTION * noise_and_light_pollution);
overall += getIndexPartPreCalc(PollutionDbEntry.IS_POLLUTION_GREEN_AND_PARKS_QUALITY * green_and_parks_quality);
overall += 2 * getIndexPartPreCalc(PollutionDbEntry.IS_POLLUTION_COMFORTABLE_TO_SPEND_TIME * comfortable_to_spend_time);

 double overallExpScale = 0.0;
 overallExpScale += 7 * getIndexPartPreCalcExpScaleStandard(PollutionDbEntry.IS_POLLUTION_AIR_QUALITY * air_quality);
 overallExpScale += 2 * getIndexPartPreCalcExpScaleStandard(PollutionDbEntry.IS_POLLUTION_DRINKING_WATER_QUALITY_ACCESSIBILITY * drinking_water_quality_accessibility);
 overallExpScale += 2 * getIndexPartPreCalcExpScaleStandard(PollutionDbEntry.IS_POLLUTION_WATER_POLLUTION * water_pollution);
 overallExpScale += getIndexPartPreCalcExpScaleStandard(PollutionDbEntry.IS_POLLUTION_GARBAGE_DISPOSAL_SATISFACTION * garbage_disposal_satisfaction);
 overallExpScale += getIndexPartPreCalcExpScaleStandard(PollutionDbEntry.IS_POLLUTION_CLEAN_AND_TIDY * clean_and_tidy);
 overallExpScale += getIndexPartPreCalcExpScaleStandard(PollutionDbEntry.IS_POLLUTION_NOISE_AND_LIGHT_POLLUTION * noise_and_light_pollution);
 overallExpScale += getIndexPartPreCalcExpScaleStandard(PollutionDbEntry.IS_POLLUTION_GREEN_AND_PARKS_QUALITY * green_and_parks_quality);
 overallExpScale += 2 * getIndexPartPreCalcExpScaleStandard(PollutionDbEntry.IS_POLLUTION_COMFORTABLE_TO_SPEND_TIME * comfortable_to_spend_time);

 index.main = overall / 14.5; //max 17
 index.expScale = calcScaleStandardIndexFromSum(overallExpScale, 12);

}

protected double getIndexPartPreCalc(double internalValue) {
return (internalValue + 2) * 25;
}

protected double getIndexPartPreCalcExpScaleStandard(double internalValue) {
return getIndexPartPreCalcExpScale(internalValue, Math.E);
}

protected double getIndexPartPreCalcExpScale(double internalValue, double exp) {
return Math.pow((internalValue + 2) * 25, exp);
}

protected double calcScaleStandardIndexFromSum(double scaleSum, int elems) {
return Math.pow(scaleSum / elems, 1 / (Math.E * 8.8 / 10));
}