Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Written in psuedocode: A. Write an algorithm that inputs the electric meter read

ID: 3662959 • Letter: W

Question

Written in psuedocode: A. Write an algorithm that inputs the electric meter readings (in kilowatt-hours) at the beginning and end of a month. It then determines the cost of electricity on the basis of a charge of 6 cents per kilowatt-hour for the rst 1,000 kilowatt-hours of the month and 8 cents per kilowatt-hour beyond 1,000. B. Now modify the algorithm that you wrote in part A, such that your algorithm will calculate the total annual cost of electricity for the 12 months of the year (use of a loop is required here).

Explanation / Answer

part A)

function Bill():
begin_read = input() # read from console, month starting reading
end_read = input() # read from console, month ending reading
total_pow = end_read - begin_read
bill = 0;
if (total_pow > 1000):
bill = 1000*6 + (total_pow-1000)*8
else:
bill = total_pow*6
return bill



b)

function Bill(begin_read,end_read):
total_pow = end_read - begin_read
bill = 0;
if (total_pow > 1000):
bill = 1000*6 + (total_pow-1000)*8
else:
bill = total_pow*6
return bill

def main():
for i = 1:12
begin_read = input() # read from console, month starting reading
end_read = input() # read from console, month ending reading
print 'bill for '+(i+1)+" Month is : "+Bill(begin_read,end_read)
end

main()