Question
Programming in C: 1. Write a program that will calculate and print bills for the city electric power company. The rates vary depending on whether
Programming in C:
1. Write a program that will calculate and print bills for the city electric power company. The rates vary depending on whether the use is residential (R), commercial (C) or industrial (I). The rates are computed as follows:
Residential: $6.00 flat fee plus $0.052 per kwh used
Commercial: $60.00 flat fee for the first 1000 kwh (or amount less than 1000 kwh) used and $0.045 for each additional kwh above 1000.
Industrial: $76.00 flat fee for the first 500 kwh (or amount less than 500 kwh) and $0.065 for each additional kwh above 500.
Your program should prompt the user to enter the number of kilowatt-hours of energy consumed and the type of use (entered as a single character), and should calculate and display the amount of the charge due from the customer with two decimal digits. Use a switch statement to handle the different types of usage. The program should allow for entry of either upper or lower case usage characters and should include an error message for entry of an invalid code character. Print the quantity calculated with 2 decimal digits.
When the program is working, modify it using a while ordowhileloop so that the program will continue prompting the user to see if another bill is to be calculated. For example, suppose that a number of kwh is entered and the user specifies that the usage rate is for residential use. After the result is printed the user will be asked if he wants to do another calculation. He might enter Y to continue or N to quit. Include entry of the kwh as well as the switch statement in the loop.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started