1,105,242 Community Members

return statement error

Member Avatar
nadiah.izzati
Newbie Poster
3 posts since Jul 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 
program WaterBill;
uses winCrt;
type
customer=record
acct_no:longint;
code:char;
liter:longint;
amount:real;
end;

var
arrayC:array[1..50] of customer;
index:integer;
loop:boolean;
continue:char;
arr:customer;

PROCEDURE read_data(var data:customer);
begin
writeln('Customer Info: ');
writeln('Account number: ');
readln(data.acct_no);
writeln('Code(H,C,I) : ');
readln(data.code);
writeln('Unit of liter: ');
readln(data.liter);
end;

function calc_bill(code:char):real;
begin
if (code='H') then
begin
if (arr.liter<=15000) then
calc_bill:=0.40*(arr.liter div 1000)
else if(arr.liter>=15001) AND (arr.liter<=40000) then
calc_bill:=(0.40*(15000/1000))+(0.70*(arr.liter div 1000))
else if(arr.liter>=40001) then
calc_bill:=(0.40*(15000/1000))+(0.70*(40000/1000))+(1.10*(arr.liter div 1000));
end

else if (code='C') then
calc_bill:=1.10*(arr.liter div 1000)

else if (code='I') then
calc_bill:=1.30*(arr.liter div 1000);

end;

PROCEDURE print_bill(var print:customer);
begin
writeln('*** A&B Water Company ***');
writeln();
writeln('Account No: ',print.acct_no);
writeln('Code(H,C,I): ',print.code);
writeln('Unit of Liter: ',print.liter);
writeln('Amount Due (RM): ',arr.amount:5:2);
end;

begin
for index:=1 to 50 do
begin
read_data(arrayC[index]);
arr.amount:=calc_bill(arrayC[index].code);
print_bill(arrayC[index]);

writeln('Do you wish to continue?(Y/N):');
readln(continue);
end;


end.

It doesn't return the amount due.

Member Avatar
pritaeas
mod_pritaeas
11,291 posts since Jul 2006
Reputation Points: 1,420 [?]
Q&As Helped to Solve: 1,832 [?]
Skill Endorsements: 155 [?]
Moderator
Featured
Sponsor
 
0
 

Assign the the value of calc_bill to result

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article