perm filename BALANC.SAI[USE,CSR] blob
sn#645887 filedate 1982-03-09 generic text, type C, neo UTF8
COMMENT ⊗ VALID 00002 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 begin "balance"
C00005 ENDMK
C⊗;
begin "balance"
comment This will scan the address file, counting the number of customers who
owe us amounts of money. The classes will be 0-10, 10-20, 20-40, and
over-40. At the end, it will print out the number in each class;
comment The program operates by retaining 4 variables, and incrementing them
each time a customer is examined. Later, we might actually print out
new files with the customers in them, or create a sorted version
of the file (sorted by amount owed);
define crlf = "('15&'12)";
comment the count variables;
integer xm, x0, x1, x2, x3, x4, total;
integer balance;
boolean eof;
integer flag, ichan, daddr, brchar, blf;
string addr;
comment Set breaktable, to read one address, up to the dollar sign;
setbreak(daddr←getbreak,"$",null,"IS");
total ← xm ← x0 ← x1 ← x2 ← x3 ← x4 ← 0;
eof←0;
comment Open channels for input and output;
open(ichan←getchan,"DSK",0,19,0,450,brchar,eof);
lookup(ichan,"ADDFIL.DSK",flag);
if flag then print("Can't find address file.",crlf);
comment The main loop. Proceed through the address file one at a time;
balance←input(ichan, daddr);
do begin "next address"
balance←intin(ichan);
if balance < 0 then xm ← xm+1
else if balance = 0 then x0 ← x0+1
else if balance ≤ 10 then x1 ← x1+1
else if balance ≤ 20 then x2 ← x2+1
else if balance ≤ 40 then x3 ← x3+1
else x4 ← x4+1;
total ← total+1;
balance←input(ichan,daddr);
end "next address"
until eof;
comment Now print out the totals;
print(crlf, "Totals:",crlf, crlf, "Number of customers: ",total, crlf,
crlf,"Below zero: ", xm, crlf, "Zero: ", x0, crlf,
"0-10: ", x1, crlf, "10-20: ", x2, crlf, "20-40: ", x3, crlf, "Over 40: ",
x4, crlf, crlf);
close(ichan);
end "balance";