Fred is a quasi-friendly guy, but in reality he is mean.
Because of this, Fred lives alone in a small apartment in Los Altos, CA. Fred is so mean because he is very particular about water. He, therefore, needs your help with figuring out what his water bill is.
Your job is to write a function or program that returns his water bill given the amount of water used as input (which is always an integer).
Water consumption comes in tiers. This means that there are ranges of prices depending on the amount of water.
These are the tiers, their prices, and the amounts of water they correspond to:
Tier I First 10 Ccf: $3.8476/Ccf Tier II Next 17 Ccf: $4.0932/Ccf Tier III All subsequent water: $4.9118/Ccf
For n hundreds of cubic feet (Ccf), there are the following additional charges as well:
CPUC fee: 1.5% of above charges LIRA quantity surcharge: $0.047*n PBOP amoritization surcharge: $0.004*n
The sum of the Tier I, Tier II, Tier III, CPUC, LIRA, and PBOP fees is the total water bill. This sum you should either return or print to the console rounded to two decimal places.
Here are two examples:
Input: 15 ... Calculations which you do not need to output but here to help explain: Tier I: 10*3.8476 = 38.476 Tier II: (15-10)*4.0932 = 20.466 Tier III: 0*4.9118 = 0 Tiers sum: 58.942 CPUC: 1.5% of 58.942 = 0.88413 LIRA: 0.047*15 = 0.705 PBOP: 0.004*15 = 0.06 Total sum: 58.942 + 0.88413 + 0.705 + 0.06 = 60.59113 ... Output: 60.59 Input: 100 ... Calculations which you do not need to output but here to help explain: Tier I: 10*3.8476 = 38.476 Tier II: 17*4.0932 = 69.5844 Tier III: (100-10-17)*4.9118 = 358.5614 Tiers sum: 466.6218 CPUC: 1.5% of = 6.999327 LIRA: 0.047*100 = 4.7 PBOP: 0.004*100 = 0.4 Total sum: 478.721127 ... Output: 478.72
This is code golf so shortest code in bytes wins!