I ran into scenario where my client wants to know the original amount after percentage deduction. They are collecting online donation where user enter its amount and then percentage values (bank charges and FED) are added in his amount to ensure that my client always get exact amount in his account after percentage deduction.
For example:
Donation amount = 32,000
Bank charges = 3%
FED charges = 13%
Calculation:
Deducting bank charges = 32000 * .03 = 960
Deducting FED on bank charges = 960 * .13 = 124.80
Total = 32000 + 960 + 124.80 = 33,084.80
I now want to reverse the amount 33,084.80 to get the exact actual amount of 32,000.
Let Bank charges = b, FED charges = f (here b=0.03, f=0.13)
Then
Donation + Donation * b + Donation * b * f = Total
Donation * (1 + b + b * f) = Total
so
Donation = Total / (1 + b + b * f)
here
Donation = 33,084.80 / (1 + 0.03 + 0.03 * 0.13) = 33,084.80 / 1.0339 = 32,000
Related
This is perhaps more of a match question, but asking here due to the constraints of the logging apparatus.
An API accepts a batch of query terms, and returns N results per query. N is a non-negative integer.
For example:
Request 1 contains 100 query terms, the first 3 of which return 2 matches each.
[0] = 2 results,
[1] = 2,
[2] = 2,
[3] = 0,
...
[99] = 0
So the average results per query = (2 results x 3 queries) / 100 queries = .06, which I log.
The problem I can't figure out is how to accurately average in subsequent requests. For example a request 2 contains a single query with returns a single result, so 1/1 = 1 result per query.
My average results per query now looks like this: (.06 + 1) / 2 = .53, which I do not think is accurate. How can I weight the first request to obtain an accurate datapoint which can then be used in an equation to track average results per query over a time?
You could weigh them by number of query terms? Then it would be (100 * .06 + 1 * 1) / (100 + 1) = .069.
Or simply (6 + 1) / (100 + 1) = .069. But it depends upon what you consider the 'correct' average of course.
r = nResults1 + nResults2 + ...
= nQueryTerms1 * avgResultsPerQuery1 + nQueryTerms2 * avgResPerQuery2 + ...
q = nQueryTerms1 + nQueryTerms2 + ...
avg = r / q
for example, I have 1 computer with a discount, the price of this computer is $ 450 with a 10% discount, I want to know the real price of it,
I want to learn this both over 10% and as 10% money.
Computer 10% off Price = 450$
Computer $10 off Price = 490$
$net_total = 450;
$discount_value = 10; < percent or amount
$gross_price = ?;
Well, let's solve the equations:
Computer 10% off Price = 450$
Computer $10 off Price = 490$
Which can be written as (let x be the initial price of the computer)
x - x * 10 / 100 = 450 # initial price - x without 10 % from x - x * 10% / 100%
x - 10 = 490 # just 10$ off
Or
0.9 * x = 450
x = 500
Finally
x = 450 / 0.9 = 500
x = 500
So from both equations we have that the initial computer's price is 500$
Edit: in general case,
if $discount_value stands for per cent (i.e. $discount_value = 10 means 10% discount) then
$gross_price = $net_total * 100.0 / (100.0 - $discount_value)
if $discount_value stands for money (i.e. $discount_value = 10 means 10$ discount), then
$gross_price = $net_total + $discount_value
suppose that data are stored on 4.7 Mbytes CDs that weight 50 grams each.suppose that an airplane carries 10^4 kg of these CDs at a speed of 1500 km/h over a distance of 5000 km.what is data transmission rate in bits per second of this system?
I would not call this 'data-transmission', but:
Amount of CD's = 10^4 / 0.05 = 2e5
Amount of bits = 4.7e6 * 8 * amount of CD's = 7.52e12
Seconds to carry data = 5000e3 / (1500/3.6) = 12000 seconds
(7.52 * 10^12)/ 12000) = 0.6Gbits/s
Discount Calculation:
Product quantity and range
1 - 10 - 1%
11 - 20 - 2%
21 - 30 - 3%
31 - 40 - 4%
41 - 50 - 5%
the above are the quantity range and their discount% given,
for example:
each product cost is 100
if i purchase 50 product then 5% discount is 250
Now if i purchase 50 products at 2 terms let say 20 and 30 then
for 20 product 2% discount = 40
for 30 product 3% discount = 90
total discount = 130
but here i have to get discount as 250,
Problem description:
the product can be purchased in n number of terms for the maximum quantity, here maximum quantity is 50. discount% for the purchased product is given from the above range. when total discount is added it should be equal. here when 50 product is purchased 250 is given as discount same 250 should be total discount even when product purchased as 20, 10, 10 in terms or 25, 25 whatever.....
plz help me with the calculation part, with some formula or anything....
I assume that you want the discount rate to always increase as the number of purchased items increases, and if that's the case, there's no way to do this.
Here's the logic. The basic equation is:
n1d1 + n2d2 + n3d3 = (n1 + n2 + n3)dx
One obvious solution to this is to have all the d's being equal, that is, all the discount rates are the same. Otherwise, there's no general solution (that is, no set of d's that will work for all n combinations -- for example, whenever all but one of the n's are zero then the d's on both sides of the equation will have to be the same, so the only general solution is that all d's are the same), and if you want a specific solution with different d's, you could solve for the correct value of d given a set of n's, but when you do that, it's clear if one of the d's is smaller than dx, another will have to be larger, so you can't have an strictly increasing discount rate.
Calculate the discount for the previous item count. (How much discount has been given before.)
Calculate the discount for the new item count (previous + current order). (How much discount the customer should have.)
Give a final discount as the difference between the two values.
Store the new item count (of each type) for the customer to some database.
float SimpleDiscount(float cost, int count)
{
if (count <= 0) return 0;
if (count <= 10) return 0.01f * cost;
if (count <= 20) return 0.02f * cost;
if (count <= 30) return 0.03f * cost;
if (count <= 40) return 0.04f * cost;
return 0.05f * cost; // count > 40
}
float GetDiscount(int customerId, int itemId, int count)
{
float cost = GetItemCost(itemId);
int previousCount = GetCustomerOrderedItemCount(customerId, itemId);
float previousDiscount = SimpleDiscount(cost, previousCount);
int newCount = previousCount + count;
float newDiscount = SimpleDiscount(cost, newCount);
SaveCustomerOrderedItemCount(customerId, itemId, newCount);
return newDiscount - previousDiscount;
}
For example:
Item cost = 100
For 20 items: Discount = 40 (2%)
For 30 items: Discount = 210 (7%)
Total discount = 250 (5%)
I have 1 result and which i will receive in Bank account, Based on that account i have to Put a balance to user account.
How can you find the Handling cost from total tried 491.50 / 0.95 = 517.36 which is wrong ? It should be 500.00 (to my expectation)
User balance requires 500.00
When 500.00 selected he gets 5% discount
There is a handling cost for this
ex:
1) Discount: 500.00 - 5% = 475.00
2) Handling cost: (475.00 x 0.034) + 0.35 = 16.50
3) Total: 475.00 + 16.50 = 491.50
So problem is from 491.50, i have to find atleast handling cost to get promised Balance.
Any solution ? Cant figure it out myself...
In short cut:
a) i put 491.50 -> b) my formula will suggest me apply balance 500.00 (which is the main goal)
So, your maths can be represented as:
((0.95 * initialCost * 0.034) + 0.35) + (0.95 * initialCost ) = finalCost
which reduces to
(0.9823 * initialCost) + 0.35 = finalCost
It follows that
initialCost = (finalCost - 0.35) / 0.9823
(final_price - 0.35) / 1.034 / 0.95
For 491.50, this yields 500.
You might try to combine the last 2 divisions to be divide by 1.034 * 0.95 = 0.9823, but you will have to guard against rounding errors due to using floating point arithmetic.