home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / mbug / mbug003.arc / PASCAL.004 < prev    next >
Text File  |  1979-12-31  |  5KB  |  112 lines

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