{***Name: Winnie Leung Class: F.4CA Class no.: 22 ***} {***This program is using arrays to stimulate the processing of electric bills of an electronic power company ***} program POWBILL (input, output); uses wincrt; const rate = 8.83; var choice, diff, ac, n : integer; month : string; powread : array[1..12] of integer; cname : string; amt : real; mth : array[1..12] of string; (*** procedure ***) procedure accdata (acc :integer; var ccname:string); begin If acc = 12836 then ccname := 'Peggy So'; diff:= 60; end; (*** Main Program ***) begin writeln('RUN'); writeln('MENU'); writeln('(1) Enter monthly readings'); writeln('(2) Search customer records'); writeln('Choose a number for your choice.'); writeln; write('Choice : '); readln(choice); mth[1] := 'JANUARY 2000'; mth[2] := 'FEBRUARY 2000'; mth[3] := 'MARCH 2000'; mth[4] := 'APRIL 2000'; mth[5] := 'MAY 2000'; mth[6] := 'JUNE 2000'; mth[7] := 'JULY 2000'; mth[8] := 'AUGUST 2000'; mth[9] := 'SEPTEMBER 2000'; mth[10] := 'OCTOBER 2000'; mth[11] := 'NOVEMBER 2000'; mth[12] := 'DECEMBER 2000'; If choice = 1 then begin write('Customer name : '); readln(cname); write('Account number : '); readln(ac); write('Billing month : '); readln(month); n :=1 ; repeat n:=n+1 until mth[n]=month; write('Last month reading : '); readln(powread[n- 1]); write('This month reading : '); readln(powread[n]); writeln; writeln('Electricity is charged at $', rate:4:2, ' per unit (kilo watt hour)'); writeln; writeln('Monthly Electric Bill'); writeln; writeln('Account number : ', ac); diff := powread[n] - powread[n - 1]; writeln('Unit of electricity consumed this month : ', diff); amt := diff * rate; writeln('This month electric charge : ', amt:0:2); end else begin write('Account number : '); readln(ac); accdata(ac, cname); writeln; writeln('Customer name : ', cname); writeln('Unit of electricity consumed this month : ', diff); amt := diff * rate; writeln('This month electric charge : ', amt:0:2); end; end.