Assignment-1 javascript question regarded doubt

i m getting confused in this question can any one help??

Write a JavaScript program to input electricity unit charge and calculate the total electricity bill according to the given condition:
For first 50 units Rs. 0.50/unit
For next 100 units Rs. 0.75/unit
For next 100 units Rs. 1.20/unit
For unit above 250 Rs. 1.50/unit. An additional surcharge of 20% is added to the bill.

Hi @shivtech1906 , can you please resolve this? The student is from FSR300623.

let say you have input of 300 units and now you have to calculate the total amount then
for first 50 units it will be 50 * 0.5 = 25 rupees (300 -50) = 250 units remaining
then, next 100 units it will be 100 * 0.75 = 75 rupee ( 300 - 50 - 100) = 150 units remaining ,
next 100 units it will be 100 * 1.20 = 120 rupee (300 - 50 - 100 - 100) = 50 units remaining
next 50 * 1.50 = 75.

total bill = 25 + 75 + 120 + 75 = 295
now additional 20 % on whole i.e., 354

@shivtech1906 thankyou sir

1 Like