Bug 384 - Incorrect return values when calculating percentage of the maximum sales
Summary: Incorrect return values when calculating percentage of the maximum sales
Status: RESOLVED FIXED
Alias: None
Product: online shop management system
Classification: Unclassified
Component: Sales System (show other bugs)
Version: 1.0.0
Hardware: PC Windows
: Normal major
Assignee: gkpcheung3-c
URL:
Depends on:
Blocks:
 
Reported: 2020-11-01 17:24 HKT by gkpcheung3-c
Modified: 2020-11-06 13:54 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 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.