I have a list of numbers (example):
98,
77,
55,
11
Which have combined value: 241
I tried to calculate the percentage using:
(int) (((double) quantity / totalQuantity) * 100);
This works (most of the times) however sometimes the combined percentage is not 100%. I tried to use Math.ceil or floor and I still encounter this problem.
edit:
Let me give a little background because you are right if my case was to calculate numbers:
I have a shipment with has total number of items 241 and I have 4 types of items (98, 77, 55, 11). I need to show to the user how many percents each shipment is.
Thank you