An Electricity Bill in Slabs

Medium

Read a meter number and the number of units consumed, both integers, and print the bill. The first 200 units cost 80 paise each, the next 100 units cost 90 paise each, and every unit beyond 300 costs Rs 1.00. Every customer pays a meter charge of Rs 100. If the total amount, energy charge plus meter charge, is more than Rs 400, add a surcharge of 15% of that total. Print six lines in exactly this form: meter number: 1234, units consumed: 250, energy charge: 205.00, meter charge: 100.00, surcharge: 0.00, total amount: 305.00, with every amount to two decimal places. If the units are negative print units cannot be negative and return 1. If the two integers cannot be read print invalid input and return 1.

Success Criteria

Your code must pass 8 test case(s) to complete this exercise. 3 hint(s) are available if you need help.

How did you find this exercise?

Your rating helps us improve the content.

Sign in to track your progress

You can work on exercises as a guest, but sign in to track your progress and save your submissions.

This platform is built by its community

Every lesson, project, and tool on HelloC++ is funded by sponsors. Join them and help shape what we build next.

Become a Patron