Bug 385 - Incorrect return values when calculating the average expenditure of each Item
Summary: Incorrect return values when calculating the average expenditure of each Item
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
: High major
Assignee: gkpcheung3-c
URL:
Depends on:
Blocks:
 
Reported: 2020-11-01 17:42 HKT by gkpcheung3-c
Modified: 2020-11-06 00:37 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:42:46 HKT
When testing the function of calculating the average expenditure of each product, the expected result and the actual result do not match.
The expected result is 169.67, but the return value of the function of salesSystem.averageExpenditure_perItem() is 169.66666666666666.
Comment 1 gkpcheung3-c 2020-11-06 00:20:46 HKT
Step of the test case:
1. Sum up all the income of the product.
2. Calculate the average expenditure by total income divided by the total number of products.
3. Calculate the expected average expenditure.
4. Compare the actual average expenditure(from step 2) with the expected average expenditure(from step 4).
Comment 2 gkpcheung3-c 2020-11-06 00:37:38 HKT
The bug fixed successfully by adding BigDecimal to round up the calculated result of the actual average Expenditure. By rounding up the result to 2 decimals, the problem can be fixed and the actual result will then equal the expected result (169.67).