Sequential Exercise 2.

Develop a program that will allow the user to enter two electricity meter readings (present and previous) and calculates the amount owed when charged at 6.67p per unit.

Algorithm

ElectricCharge
    cost per unit:= 6.67 {alternatively use 0.667 to alleviate using the divide by 100}
    read present meter reading
    read previous meter reading
    amount owed:= (present meter reading-previous meter reading)*6.67/100 {to convert to £}
    write amount owed
End.

Alternative algorithm

ElectricCharge
    cost per unit:= 6.67
    read present meter reading
    read previous meter reading
    electicity used:=
present meter reading-previous meter reading
    amount owed:= electricity used*6.67/100 {to convert to £}
    write amount owed
End.

PROGRAM: electric.cpp