home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
mbug
/
mbug003.arc
/
PASCAL.004
< prev
next >
Wrap
Text File
|
1979-12-31
|
5KB
|
112 lines
PASCAL_FOR_BASIC_PROGRAMMERS.
Dixon Kenney
PART IV.
Let'≤á continuσ oε witΦ thσ Bankinτ program«á Here'≤ thσ nex⌠ versioε ì
oµ it.
1ááááPrograφ Banking_3;
2áááá√ *¬ Versioε 3 oµ thσ Bankinτ prograφ read≤ transactions
3áááá *¬ int∩ aε array¼ anΣ print≤ ou⌠ ß Banδ statement« I⌠ will
4áááá *¬ givσ ß warninτ at the end of the run iµ thσ accoun⌠
** i≤ overdrawε }
6ááááConst
á7áááá Ma° ╜ 10╗ √ uppe≥ limi⌠ fo≥ numbe≥ oµ
áááááá transactions }
á9ááááVar
10áááá CustNamσ ║ String[20];
11áááá AccNum¼ Inde° ║ Integer;
12 áá OpBalance¼ Transaction¼ CBalancσ ║ Real;
13áááá Tran≤á ║áarra∙█▒.«Ma°▌oµ Real;
15ááááBegiε √ oµ maiε prograφ }
16áááá ClrScr╗ √ Typσ iε transactioε detail≤ }
17áááá Writeln╗ Writeln;
18 ááá Write('Custome≥ Namσ ║ ')╗ Readln(CustName);
19áááá Write('Accoun⌠ Numbe≥ ║ ')╗ Readln(AccNum);
20áááá Write('Openinτ Balance║ ')╗ Readln(OpBalance);
21áááá CBalancσá:╜áOpBalance╗á√assigε OpBalancσát∩árunninτ Balancσ}
22áááá Writeln('Typσ iε Transactioε amount≤ ');
23áááá Fo≥ Inde° :╜ ▒ t∩ Ma° do
24áááá Begin
25 áá Write('Transactioε '¼ Index:3¼ º ║ ');
26 Readln(Trans[Index])
27áááá End╗ √ oµ transactioε typσ iε }
29áááá ClrScr╗ √ Prin⌠ ou⌠ thσ statemen⌠ }
30áááá Writeln('Accoun⌠ Number':20¼ 'Custome≥ Name':20);
31áááá Writeln;
32áááá Writeln(AccNum:20¼ CustName:20);
33áááá Writeln;
35áááá Writeln('Debits':15¼ 'Credits':15¼ 'Balance':15);
36 ááá Writeln('Openinτ Balance':15¼ º ':15¼ OpBalance:15:2);
37áááá Fo≥ Inde° :╜ ▒ t∩ Ma° d∩ √Prin⌠ ou⌠ transaction≤ ª balance≤}
38áááá Begin
39áááá CBalancσ :╜ CBalancσ ½ Trans[Index];
40áááá Iµ Trans[Index▌ ╝ 0.░ then
41áááá Writeln(Trans[Index]:15:2¼ º ':15¼ CBalance:15:2)
42áááá Else
43áááá Writeln(º ':15¼ Trans[Index]:15:2¼ CBalance:15:2)
44áááá End╗ √ writinτ ou⌠ transaction≤ ª balances }
46áááá Writeln;
47áááá Iµ CBalancσ ╝ 0.░ theε √ prin⌠ ou⌠ ß nast∙ messagσ }
48áááá Writeln('You≥ accoun⌠ i≤ overdrawε !');
50ááááEnd« √ *¬ Prograφ Bankinτ 3 }
è Iε Linσ 7¼ wσ arσ defininτ ß variablσ a≤ ß maximuφ numbe≥ - oµ course¼ ì
thσ labe∞ i≤ choseε fo≥ ou≥ conveniencσ - i⌠ mean≤ nothinτ t∩ thσ computer« ì
B∙ defininτ ß variable¼á anΣ theε usinτ i⌠ throughou⌠ thσ program¼á wσ onl∙ ì
havσá t∩á makσ onσ changσ iµ wσ wan⌠ t∩ havσ morσ transaction≤á - wσá don'⌠ ì
havσá t∩ searcΦ througΦ thσ wholσ prograφ t∩ changσá parameters¼á anΣá hopσ ì
tha⌠ we'vσ founΣ thσ lot.
Iε Linσ 13¼ wσ definσ aε array« Aε arra∙ iε Pasca∞ caε bσ oµ an∙ Datß ì
Type╗á the∙ arσ no⌠ limiteΣ t∩ beinτ defineΣ iε thσ standarΣ types« Noticσ ì
║á a⌐ thσ worΣ ARRAY╗á b⌐ thσ usσ oµ squarσ bracket≤ t∩ definσ thσ inde° oµ ì
thσá array╗á c⌐ thσ lowe≥ anΣ uppe≥ bound≤ oµ thσ arra∙ arσ separateΣ b∙á 2ô ì
ful∞ stops╗á d⌐ wσ mus⌠ usσ thσ worΣ O╞ t∩ introducσ thσ datß type╗á e⌐ thσ ì
datß type.
áááááááááIε BASIC¼á thσ DI═ statemen⌠ assume≤ ß lowe≥á bounΣ ì
áááááááááoµ ░ o≥ 1¼á dependinτ oε thσ versioε oµ BASI├ used« ì
áááááááááOnl∙ thσ uppe≥ bounΣ i≤ defined«á Thσ datß typσ i≤ ì
ááááááááádefineΣá b∙ thσ variablσ - althougΦ iε BE┼ BASI├á ß ì
ááááááááástrinτ arra∙ i≤ defineΣ iε ß wa∙ whicΦ i≤ distinct-ì
ááááááááály different from other BASICS.
Thσá bound≤ caε bσ defineΣ b∙ constants¼á a≤ i≤ donσ here«á Thσá lowe≥ ì
bounΣ oµ thσ arra∙ - herσ i⌠ i≤ ▒ - neeΣ no⌠ bσ ░ o≥ 1╗á wσ coulΣ definσ aε ì
arra∙ a≤ lyinτ betweeε 1╡ anΣ 3▓ iµ wσ wished.
Iε Linσ 3╖ wσ begiε ß compounΣ FO╥ statement«á Noticσ thσ usσ oµá thσ ì
BEGI╬á .«á EN─á pai≥á oµ words«á Here¼á EN─ iε linσ 4┤á function≤á a≤á thσ ì
delimite≥ fo≥ thσ loo≡ beguε iε linσ 37/8.
Line≤á 4▒ anΣ 4│ arσ formatteΣ s∩ tha⌠ thσ informatioε wil∞ bσ printeΣ ì
ou⌠ correctly«á Column≤ oµ 1╡ character≤ arσ defined¼á witΦ thσ irrelevan⌠ ì
mone∙ columε beinτ blankeΣ out.
Iµ yo⌡ wanteΣ to¼á yo⌡ coulΣ se⌠ u≡ aε underlininτ line«á I⌠ coulΣ bσ ì
placeΣ afte≥ line≤ 3▓ (t∩ rulσ ofµ thσ custome≥ informatioε line)¼á 3╡á (t∩ ì
rulσá ofµá thσá columεá headers)¼á anΣá 4┤ (t∩ rulσá ofµá thσá enΣá oµá thσ ì
statement)« I⌠ coulΣ bσ defineΣ a≤ ß constan⌠ - yo⌡ coulΣ adΣ afte≥ linσ 7«
Ruler = '---'
witΦ thσ '-º beinτ repeateΣ 4╡ times¼ anΣ issuinτ ß WRITELN(Ruler)« O≥ yo⌡ ì
coulΣ se⌠ i⌠ u≡ iε ß loo≡ -
For Counter := 1 to 45 do
write('-');
Writeln
B∙ usinτ WRITE('-'⌐ thσ effec⌠ i≤ tha⌠ oµ ß PRINT"-"╗á statement« Thσ ì
WRITEL╬á i≤ theε necessar∙ t∩ senΣ ß CR/L╞ character«á Noticσ tha⌠ iε thi≤ ì
loop¼á thσ terminatioε i≤ thσ semi-coloε - i⌠ i≤ ß simplσá statement¼á witΦ ì
onl∙á onσá statemen⌠ afte≥ thσ loo≡ i≤ se⌠ up¼á s∩ therσ i≤ n∩ neeΣá fo≥á ß ì
BEGI╬ .« EN─ pair« Thσ 45¼ oµ course¼ i≤ 15+15+15.
END OF PART FOUR.