Write a program that calculates electricity fee using domestic rate according to the following
Web site http://www.mea.or.th/profile/index.php?l=th&tid=3&mid=111&pid=109. We use sections 1.1
and 1.2 and assume that user’s meter is not greater that 5 amperes, 1 phase and 2 lines. This implies when a
user consumes more than 150 units for consecutive 3 months, the rate in the next month will be according to
1.2. If the rate used is 1.2, and the users use electricity not greater than 150 units for consecutive 3 months,
next months will use the rate in 1.1. This is specified in items 1 and 2 in the remark. However, we do not
consider item 6 in the remark.
The program should receive units of electricity used and ask whether it is the end of a month. If it is
not the end of a month, the program continues asking for the units. If it is the end of a month, the program
calculates the fee and displays the accumulated units and the fee. Then it keeps asking for units for next
month. If the user would like to quit the program, he/she enters ‘q’ when it is asking for the end of the
month.
An example of the program is shown in the next page. Note that after using 500 units for consecutive
3 months, the fee is changed because the rate in 1.2 is applied. Then after using 100 units (not more than
150 units) for consecutive 3 months, the fee is changed again since the rate in 1.1 is applied again.