Computer Science Pseudocode Algorithm problem?
Computer Science Pseudocode Algorithm problem? I need to create an algorithm for the following problem in Pseudo-code.
Write an algorithm that is given your electric meter reading (in
kilowatt-hours) at the beginning and end of each month of the year.
The algorithm determines your annual cost of electricity on the basis
of a charge of .06 cents per kilowatt-hour for the first 1000
kilowatt-hours of each month and .08 cents per kilowatt-hours beyond
1000.After printing your total annual charge, the algorithm also
determines whether you used less than 500 kilowatt-hours for the
entire year. If so, it prints out a message thanking you for
conserving electricity.
My main issue is that I do not know how I would keep the totals for each month separate without creating a different input for each one.
This is what I have so far:
Months (M) = 1
While M 12
Input Beginning of Month (B)
Input End of Month (E)
Monthly total (MT) = E-B
IF MT1000
Overage (O) = MT - 1000
Overage-Cost (OC) = O * .08
MT - O = Non-overage (NO)
Non-overage Cost (NOC) = NO * .06
Monthly Cost (MC) = NOC + OC
Else
MT *.06 = MC
And then I am stuck. because that just calculates 1 month. Any help would be greatly appreciated.
|