|
|
Gas Company |
Flatulence Gas, charges its customers based on the following consumption table:
|
Gas
Usage |
Rate |
|
First 70 cubic meters |
$5.00 minimum cost |
|
Next 100 cubic meters |
5.0¢ |
|
Next 230 cubic meters |
2.5¢ |
|
Above 400 cubic meters |
1.5¢ |
They have hired you to write their interactive billing program.
Write a complete C++ program that computes the charges for a given amount of gas usage. The program first asks the customer for their first and last names. The program prompts the customer for his current and last month’s meter reading. The current meter reading and previous readings are entered as a number with up to four digits, (make sure you print an error message if input is incorrect) representing the amount of gas used in cubic meters.
It then asks the customer if last month’s bill was paid in full. If the customer answers no, the program further inquires as to the amount paid in the previous month. The program then calculates the current monthly charge and the balance due.
Note: The current reading may be less than the previous one; for example, the previous reading may be 9897 and the current one may be 103.
Execute the program with the following meter readings: 3450, 3495; 8810, 8900; 9950, 190; 1275, 1982; 9872, 444
Your output should display the customer’s bill including the customer’s full name, last month’s meter reading, last month’s balance, amount paid last month, this month’s balance and the amount due. Organize the bill so that it is neat and professional.