Example 18: Calculate Utility Bill
Learn how to calculate the monthly electricity bill based on the given criteria.
We'll cover the following
Problem
An electricity utility company charges its customers on the following basis depending on the category they belong to and the units they have consumed for the month:
Category | Fixed Cost | Units Consumed / Load | Price |
---|---|---|---|
Residential | $50/month for 1-phase meter $200/month for 3-phase meter |
0 to 100 units 101 to 300 units 301 to 500 units > 500 units |
$3.76 / unit $7.21 / unit $9.95 / unit $11.31/ unit |
Commercial | $220/ month | 0 to 200 units > 200 units |
$6.60 / unit $9.62 / unit |
Industrial | $250 / month | 0 to 20 KW > 20 KW |
$5.43 / unit $6.88 / unit |
Agricultural | $340 / month | 0 to 5 HP > 5 HP |
$258 /HP /month $360 /HP /month |
Example
Input (Category) | Input (Meter) | Input (Units Consumed / Load) | Output |
---|---|---|---|
Residential | Three Phase Meter | 345 | 3632.750000 |
Commercial | Nil | 195 | 1507.000000 |
Industrial | Nil | 22 | 401.359985 |
Agricultural | Nil | 15 | 5740.000000 |
Try it yourself
Try to solve this question on your own in the code widget below. If you get stuck, you can always refer to the solution provided.
❗Note: To run your solution or our given solution, follow the following steps:
- Click on the run button.
- Wait for the 4 steps to complete, then switch to the terminal tab.
- In the terminal tab, write the following command:
gcc main.c -o main
Follow it with this command:
./main
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.