Bug 384

Summary: Incorrect return values when calculating percentage of the maximum sales
Product: online shop management system Reporter: gkpcheung3-c
Component: Sales SystemAssignee: gkpcheung3-c
Status: RESOLVED FIXED    
Severity: major CC: nokyinng3-c
Priority: Normal    
Version: 1.0.0   
Hardware: PC   
OS: Windows   

Description gkpcheung3-c 2020-11-01 17:24:16 HKT
The bug found when testing calculating the percentage of the product with maximum sales.

The expected result of this test case should be 50.0 but the actual result is 0.0.
Comment 1 gkpcheung3-c 2020-11-06 00:26:31 HKT
Step of the test:
1. Find the maximum sales of the product in the database.
2. Calculate the percentage by maximum sales divided by the total number of sales.
3. Round up the result.
4. Calculate the expected percentage.
5. Compare the actual percentage(from step 2 and 3) with the expected percentage(from step 4).
Comment 2 gkpcheung3-c 2020-11-06 00:46:52 HKT
The bug fixed successfully. The bug was fixed by adding a statement to convert the type of max and totalSales from int to double. Otherwise, in the test case, the result of max divided by totalSales will be incorrect as the type is int. To get the correct calculation, the type needs to convert to double first.