Bug 636 - Location Score conversion calculation problem
Summary: Location Score conversion calculation problem
Status: RESOLVED FIXED
Alias: None
Product: 2021 CS3343 Hall Admission System
Classification: Unclassified
Component: Scoring and Weighting Record Section (show other bugs)
Version: unspecified
Hardware: PC Windows
: High major
Assignee: Azim
URL:
Depends on:
Blocks:
 
Reported: 2021-12-04 15:25 HKT by amble3232
Modified: 2021-12-04 15:27 HKT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description amble3232 2021-12-04 15:25:11 HKT
Background:
I am doing the unit testing in Eclipse 2021-06 (4.20.0) on method convertScore() in Area_Location class.
I am testing some locations like Hung Shui Kiu, with similar characteristics that the converted score calculation result is not an integer

Steps to Reproduce:
1. Run the package with testHall_Admission
2. Run the method “void testConvertScore” in testArea_eca class
3. Run @ParameterizedTest with “/testResource/testCreateArea_eca.csv”
4. Input the test case "Hung Shui Kiu"

Actual result:
After the run the above steps, the system returns “0.0” and show the error “org.opentest4j.AssertionFailedError: Test convert Hung Shui Kiu to score ==> expected: <8.0> but was: <0.0>” in the console.

Expected result:
I expect the system to return “8.0” and pass the assertEquals.
Comment 1 newbie 2021-12-04 15:27:15 HKT
The input of “Hung Shui Kiu” into the method convertScore() in Area_Location class should have returned “8.0”. Therefore it is a bug. I expect the bug is within method convertScore() in Area_Location class. 

I will pass it to the developer to solve this bug.
Comment 2 Azim 2021-12-04 15:27:49 HKT
I just checked the method Area_Location and the return has a problem. It should have rounding in the calculation not just “return locationScore[i]/100*10;”.

To solve the number rounding problem, the return statement was trained.

Solution:
===============
public static int convertScore(String rawData) {
	for (int i = 0; i < locationList.length; i++) {
		if(rawData.equals(locationList[i])) {
			return (int) Math.round(locationScore[i]/100.0*10.0);
		}
	}
}