home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
mbug
/
mbug003.arc
/
PASCAL.003
< prev
next >
Wrap
Text File
|
1979-12-31
|
6KB
|
148 lines
PASCAL_FOR_BASIC_PROGRAMMERS.
Dixoε Kenney.
PAR╘ III.
Iεá thi≤á par⌠á oµ thσ series¼á wσ wil∞ looδ a⌠á assigninτá value≤á t∩ ì
variable≤ withiε thσ program¼á anΣ thσ I╞ .«á THE╬ construct« Looδ a⌠ thi≤ ì
listinτ -
Ö 1Ö Prograφ Banking_2a;
Ö 3Ö √ *¬ Versioε 2ß oµ thσ Bankinτ prograφ accept≤ onσ transaction
Ö 4Ö *¬ froφ thσ keyboard¼ calculate≤ ß ne≈ balance¼ anΣ print≤ out
Ö 5Ö *¬ thσ relevan⌠ informatioε oε thσ screen}
Ö 7Ö √ *¬ Declaratioε Par⌠ }
Ö 9Ö Var
11Ö CustNamσ ║ String[20];
12Ö AccNuφ ║ Integer;
13Ö OpBalance¼ Transaction¼ CBalancσ ║ Real;
15Ö √ *¬ Prograφ Bod∙ }
17Ö Begin
19Ö ClrScr;
20Ö Writeln╗ Writeln;
21Ö Write('Custome≥ Namσ ║ ');
22Ö Readln(CustName);
23Ö Write('Accoun⌠ Numbe≥ ║ ');
24Ö Readln(AccNum);
25Ö Write('Openinτ Balance║ ');
26Ö Readln(OpBalance);
27Ö Write('Amoun⌠ oµ Transaction║ ');
28Ö Readln(Transaction);
30Ö √ *¬ Calculatσ thσ ne≈ balancσ }
32Ö CBalancσ :╜ OpBalancσ ½ Transaction;
34Ö √ *¬ Writσ ou⌠ thσ ne≈ informatioε oε thσ screeε }
36Ö ClrScr;
37Ö Write('Accoun⌠ Number':20);
38Ö Write('Custome≥ Name':20);
39Ö Writeln╗ Writeln;
40Ö Write(AccNum:20);
41Ö Write(CustName:20);
42Ö Writeln╗ Writeln;
43Ö Write('Openinτ Balancσ ║ ');
44Ö Writeln(OpBalance:10:2);
45Ö Write('Transactioε Amoun⌠ ║ ');
46Ö Writeln(Transaction:10:2);
47Ö Write('Closinτ Balancσ ║ ');
48Ö Writeln(CBalance:10:2)
50Ö ô End.ô √ *¬ Prograφ Bankinτ 2ß }è Iε linσ 13¼á wσ havσ addeΣ tw∩ morσ variablσ name≤ t∩ thσ lis⌠ oµ rea∞ ì
number≤á whicΦ occu≥ iε thσ program«á Notσ ho≈ wσ havσ pu⌠ theφ al∞ oε onσ ì
line«á The∙á caεá bσá entereΣ eithe≥ separately¼á o≥á oεá thσá samσá line¼ ì
dependinτ oε you≥ programminτ style.
Iεá linσ 32¼á wσ havσ ou≥ firs⌠ assignmen⌠ statement«á Wσ havσ haΣ t∩ ì
declarσá thσá existencσ oµ thσ variable≤ t∩ thσ prograφ beforσ wσá caεá usσ ì
theφ - thi≤ wa≤ donσ iε linσ 13«á Noticσ thσ assignmen⌠ sign« I⌠ i≤ NO╘ █ ì
╜á ▌á a≤ iε BASIC¼á bu⌠ █ :╜ ]«á ╔ havσ founΣ tha⌠ onσá oµá BASIC'≤á grea⌠ ì
weaknesse≤á i≤á thσá usσ oµ thσ █ ╜ ▌ fo≥ tw∩á distinc⌠á meanings«á Pasca∞ ì
clear≤ thi≤ up.
╜ ha≤ thσ meaninτ "i≤ equa∞ t∩ (logically)
:╜ ha≤ thσ meaninτ "i≤ assigneΣ thσ valuσ of"
Iε BASIC¼ thσ equivalen⌠ statemen⌠ i≤ LET.
Usσ thσ █ :╜ ▌ assignmen⌠ symbo∞ whereve≥ yo⌡ woulΣ usσ LE╘ iε BASIC.
No≈á let'≤ var∙ thσ prograφ b∙ havinτ i⌠ prin⌠ ou⌠ ß nast∙ messagσá iµ ì
thσá custome≥á trie≤á t∩ overdra≈ hi≤ account¼á anΣá no⌠á allowinτá sucΦá ß ì
withdrawa∞ t∩ takσ place« Thσ firs⌠ 2╕ line≤ oµ thi≤ pro-graφ arσ thσ samσ ì
a≤ 2a¼ s∩ I'l∞ omi⌠ theφ t∩ savσ space.
Ö ▒ Ö Prograφ Banking_2b;
30Ö √ *¬ Tes⌠ t∩ seσ iµ thσ custome≥ ha≤ enougΦ money;
31Ö *¬ iµ so¼ calculatσ thσ ne≈ balancσ }
33Ö Iµ OpBalancσ ½ Transactioε ╝ 0.░ then
34Ö Beginô √ prin⌠ ß nast∙ messagσ }
35Ö ClrScr;
36Ö Writeln╗ Writeln;
37Ö Writeln('Insufficien⌠ Fund≤ - d∩ no⌠
allo≈ Withdrawal');
38Ö Delay(3000);
39Ö ClrScr
40Ö Endô √ iµ CBalancσ ╝ ░ }
41Ö Else
42Ö Begin
43Ö CBalancσ :╜ OpBalancσ ½ Transaction;
44Ö ClrScr;
45Ö Write('Accoun⌠ Number':20);
46Ö Write('Custome≥ Name':20);
47Ö Writeln╗ Writeln;
48Ö Write(AccNum:20);
49Ö Write(CustName:20);
50Ö Writeln╗ Writeln;
51Ö Write('Openinτ Balancσ ║ ');
52Ö Writeln(OpBalance:10:2);
53Ö Write('Transactioε Amoun⌠ ║ ');
54Ö Writeln(Transaction:10:2);
55Ö Write('Closinτ Balancσ ║ ');
56Ö Writeln(CBalance:10:2)
57Ö Endô √ elsσ allo≈ thσ transactioε }
59Ö End.ô √ *¬ Prograφ Bankinτ 2ß }
è Iεá linσá 3│á oµá versioε 2Γ wσ havσ aεá I╞á .«á THE╬á construct«á I⌠ ì
function≤á iε exactl∙ thσ samσ wa≤ a≤ BASI├ does¼á eveε t∩ havinτá aεá ELS┼ ì
statemen⌠ ¿ linσ 4▒ )«á However¼á ß compounΣ blocδ oµ statement≤ iε eithe≥ ì
thσá THE╬á blocδ ¿ o≥ thσ ELS┼ blocδ iµ i⌠ exist≤ ⌐ i≤ markeΣ iε thσá usua∞ ì
Pasca∞á wa≤ witΦ thσ reserveΣ word≤ BEGI╬ anΣ EN─ ¿ noticσ line≤ 34/4░á anΣ ì
42/5╖ )«á Noticσ tha⌠ therσ i≤ n∩ semi-coloε afte≥ thσ THEN¼ no≥ beforσ o≥ ì
afte≥ thσ ELS┼ statement«á Word≤ sucΦ a≤ these¼ anΣ END¼ arσ considereΣ t∩ ì
bσ statemen⌠ separator≤ iε thei≥ owε right¼ anΣ don'⌠ neeΣ thσ █ ╗ ▌ signa∞ ì
arounΣ them.
Iε linσ 3╕ therσ i≤ ß timinτ loop« Thi≤ function¼ likσ other≤ wσ havσ ì
used¼á i≤ peculia≥ t∩ Turb∩ Pascal«á Thσ dela∙ i≤ timeΣ iε millisecond≤á - ì
herσá wσ arσ delayinτ executioε oµ thσ prograφ fo≥ 300░ milliseconds¼á o≥ │ ì
seconds«
Iε BE┼ BASIC¼ thσ equivalen⌠ oµ thi≤ statemen⌠ i≤ PLA┘ 0,24.Ö
Remembe≥ tha⌠ iε thσ prograφ listing≤ iε thi≤ series¼ thσ linσ number≤ ì
arσá addeΣ fo≥ conveniencσ oµ reference¼á anΣ arσ NO╘ par⌠ oµ thσá program« ì
Pasca∞á doe≤á no⌠ usσ linσ numbers«á Thσ word≤á under-lineΣá arσá reserveΣ ì
words¼á whicΦá canno⌠ bσ re-defined«á The∙ arσ no⌠ underlineΣ wheε yo⌡ arσ ì
writinτ you≥ program╗ therσ arσ underlineΣ herσ simpl∙ t∩ dra≈ attentioε t∩ ì
them.
END OF PART THREE.