Electric Bill Calculation:
Develop an application to produce an electric bill. The data file has these fields:
Columns 1 - 19 - customer name
Column 20 - 23 - the electric meter reading after last month
Columns 24 - 26 - not used in this program
Columns 27 - 30 - the electric meter reading this month
You will need to calculate the number of kilowatt hours used, and the amount of the electric bill as follows:
for up to the first 100 KWH used, the bill will be $10 plus .25 times the number of KWH used
for 101 to 500 KWH used, the bill will be .235 (23 and one-half cents) per KWH used OVER 100 plus the amount for 100 KWH (10 + 100 * .25 or $35)
for 501 to 1000 KWH used, the bill will be .205 (20 and one-half cents) per KWH used over 500 plus the amount for 100 KWH plus the amount for the next 400 KWH. (Hint this gets a little complicated - something like this:
IF KWH-USED > 501 AND <= 1000
COMPUTE BILL = 35 + 94 + .205 * (KWH-USED - 500)
END-IF
The first 35 is from the first 100 KWH-Used ( 10 + .25 * 100
The next 94 is from the next 400 KWH-Used (400 * .235)The evaluate statement might be very useful here!!!
For any KWH used over 1000, the bill be be .175 per KWH used over 1000 plus the amount for the first 100 KWH, the next 400 KWH and the next 500 KWH.
NOTE - there will be three individuals where the meter "rolls" over. That is something like this - last month's reading: 9990 this month's reading - 0010. So they used 20 KWH. You will need to handle this situation. (Hmmm - if new-reading-in < old-reading-in . . . do something . . . like add 10000 to the new-reading????)
Additional features:
1) Put a page routine so the output will go to a new page if the number of detail lines is over 40 (or so)
2) Put a routine to handle getting and printing the date (see the textbook )
3) Put a routine in to handle getting the high person
(to get the high person, initialize the HIGH-BILL to zero, then check each time through the loop to see if the bill that was just calculated is higher than the HIGH-BILL, in which case move the current bill to the high-bill field and move the name to the high-name field)
Your output should be like this:
The basic program is like this: