home *** CD-ROM | disk | FTP | other *** search
/ Brotikasten / BROTCD01.iso / lern / lern451.d64 / stock.c (.txt) < prev    next >
Commodore BASIC  |  1995-08-09  |  10KB  |  304 lines

  1. 1 REM BY MIKE FLAVEL
  2. 2 REM REVISED FROM APPLE VERSION
  3. 10 C=0:D=0:A=0:ASSETS=0:B=0:BEGINC=10000:BUY=0:WAS=0:BROKER=0
  4. 20 CASH=10000:CHANGE=0:DAY=0:FEES=0:FLAG=0:INCOME=0:KEY=0:LAST=0
  5. 30 MARKET=-1:MOTH=0:PRICE=0:SELL=0:SHARES=0:QUARTER=0
  6. 40 SKS=12:IME=1000:WEEK=0:YEAR=1979:AVERAGE=0:E=0:F=0:G=0:H=0
  7. 50 DIMNAME$(SKS),DAY$(5),MOTH$(12),TABLE(SKS,5)
  8. 60 DISK$="":A$="":CHANGE$="":CHECK$="":IN$=""
  9. 70 NAME$(1)="ALCOA ALUMINUM":NAME$(2)="COMMODORE":NAME$(3)="CBS INDUSTRIES"
  10. 80 NAME$(4)="EXXON OIL":NAME$(5)="GENERAL MOTORS":NAME$(6)="HONEYWELL CORP."
  11. 90 NAME$(7)="IBM CORPORATION":NAME$(8)="INTEL CORP.":NAME$(9)="LOCKHEED CORP."
  12. 100 NAME$(10)="MOTOROLA":NAME$(11)="STANDARD OIL":NAME$(12)="3-M CORPORATION"
  13. 110 FORA=1TOSKS:FORB=1TO4:TABLE(A,B)=0:NEXTB,A
  14. 120 PRINT"[147]********************":
  15. 121 PRINTTAB(10)"**  MARKET CRASH  **"
  16. 130 PRINTTAB(10)"** BY MIKE FLAVEL **":PRINTTAB(10);"********************"
  17. 140 FORA=1TOSKS:PRICE=INT(RND(1)*100+1)+20:WAS=WAS+PRICE:TABLE(A,1)=PRICE
  18. 150 CHANGE=INT(RND(1)*5)-2:TABLE(A,5)=CHANGE
  19. 160 NEXTA:WAS=INT(WAS/SKS*100)/100:AVERAGE=WAS
  20. 170 MOTH$(1)="JANUARY":MOTH$(2)="FEBRUARY":MOTH$(3)="MARCH"
  21. 180 MOTH$(4)="APRIL":MOTH$(5)="MAY":MOTH$(6)="JUNE"
  22. 190 MOTH$(7)="JULY":MOTH$(8)="AUGUST":MOTH$(9)="SEPTEMBER"
  23. 200 MOTH$(10)="OCTOBER":MOTH$(11)="NOVEMBER":MOTH$(12)="DECEMBER"
  24. 210 DAY$(1)="MONDAY":DAY$(2)="TUESDAY":DAY$(3)="WEDNESDAY":DAY$(4)="THURSDAY"
  25. 215 DAY$(5)="FRIDAY"
  26. 220 WEEK=0:DAY=0:MOTH=1:LAST=31:QUARTER=0
  27. 225 INPUT" DEUTSCHE ANLEITUNG J/N";DE$
  28. 226 IF DE$="J"THEN GOSUB 4600:GOTO330
  29. 230 PRINT"[147]DO YOU WANT INSTRUCTIONS? Y/N":GOSUB2620:IFKEY=206THEN650
  30. 240 PRINT"[147]";TAB(10)"INSTRUCTIONS[146]"
  31. 250 PRINT" THIS IS A SIMULATION OF THE OPERATIONS OF THE STOCK MARKET.THERE ARE";
  32. 260 PRINT" 12        COMPANY STOCKS AVAILABLE FOR TRADE"
  33. 270 PRINT"PROVIDING YOU HAVE THE MONEY, THERE IS A BROKERS FEE OF 6% OR $50.00 PER";
  34. 280 PRINT"STOCK.  TRANSACTIONS ARE COLLECTED AT THE END OF EACH WEEK"
  35. 290 PRINT"HERE ARE THE KEY FUNCTIONS:"
  36. 300 PRINT"(S) SELL STOCK":PRINT"(B) BUY STOCK":PRINT"(RETURN) PASS":PRINT"(E) END GAME"
  37. 310 PRINT"WHEN BUYING OR SELLING STOCK ENTER AT   LEAST THE FIRST THREE INITIALS "
  38. 320 PRINT"OF THE STOCK NAME"
  39. 330 PRINT"PRESS ANY KEY TO CONTINUE"
  40. 340 GOSUB2620:IFKEY=195THEN2560
  41. 650 REM
  42. 700 REM MAIN PROGRAM
  43. 710 GOSUB830
  44. 720 GOSUB1300
  45. 730 GOSUB1750
  46. 740 GOSUB1910
  47. 750 IFKEY=194ORKEY=211THEN780
  48. 760 IFKEY=197THEN2360
  49. 770 GOTO700
  50. 780 GOSUB1970
  51. 790 IFKEY=194THENGOSUB2070
  52. 800 IFKEY=211THENGOSUB2210
  53. 810 GOSUB1910
  54. 820 GOTO750
  55. 830 REM DATA FIGURES
  56. 840 MARKET=MARKET+INT(RND(1)*3)-1:IFMARKEY>2THENMARKEY=2
  57. 850 IFMARKET<-3THENMARKET=-3
  58. 860 IFRND(1)>.92THENMARKET=-1*MARKET
  59. 870 FLAG=0:WEEK=WEEK+1:DAY=DAY+1:IFDAY<=LASTTHEN910
  60. 880 DAY=DAY-LAST:MOTH=MOTH+1:IFMOTH>12THEN2890
  61. 890 QUARTER=QUARTER+1:IFQUARTER<>3THEN910
  62. 900 QUARTER=0:GOSUB1670
  63. 910 IFWEEK<=5THEN950
  64. 920 PRINT"[147]":LAST=28:IFMOTH=4ORMOTH=6ORMOTH=9ORMOTH=11THENLAST=30
  65. 930 IFMOTH=1ORMOTH=3ORMOTH=5ORMOTH=7ORMOTH=8ORMOTH=10ORMOTH=12THENLAST=31
  66. 940 FLAG=1:WEEK=0:A$="":GOTO1200
  67. 950 GOSUB1630:IFMOTH=1ANDDAY=1THEN1060
  68. 960 IF MOTH=2ANDDAY=12THENGOTO1070
  69. 970 IFMOTH=2ANDDAY=19THENGOTO1080
  70. 980 IFMOTH=5ANDDAY=28THENGOTO1090
  71. 990 IFMOTH=7ANDDAY=4THENGOTO1100
  72. 1000 IFMOTH=9ANDDAY=3THENGOTO1110
  73. 1010 IFMOTH=10ANDDAY=8THENGOTO1120
  74. 1020 IFMOTH=11ANDDAY=12THENGOTO1130
  75. 1030 IFMOTH=11ANDDAY=22THENGOTO1140
  76. 1040 IFMOTH=12ANDDAY=25THENGOTO1150
  77. 1050 GOTO1190
  78. 1060 A$="[147]NEW YEAR'S DAY":GOTO1160
  79. 1070 A$="[147]LINCOLN'S BIRTHDAY":GOTO1160
  80. 1080 A$="[147]WASHINGTON'S BIRTHDAY":GOTO1160
  81. 1090 A$="[147]MEMORIAL DAY":GOTO1160
  82. 1100 A$="[147]INDEPENDENCE DAY":GOTO1160
  83. 1110 A$="[147]LABOR DAY":GOTO1160
  84. 1120 A$="[147]COLUMBUS DAY":GOTO1160
  85. 1130 A$="[147]VETERANS DAY":GOTO1160
  86. 1140 A$="[147]THANKSGIVING DAY":GOTO1160
  87. 1150 A$="[147]CHRISTMAS"
  88. 1160 PRINTA$:FORA=1TO1000:NEXTA
  89. 1170 PRINTTAB(9)"STOCK MARKET CLOSED...":FORA=1TO1000:NEXTA:PRINT"[147]"
  90. 1180 GOTO870
  91. 1190 GOSUB1420:IFFLAG=0THENRETURN
  92. 1200 PRINTTAB(3)"WEEKEND":PRINTTAB(9)"STOCK MARKET CLOSED..."
  93. 1210 PRINT:PRINT:GOSUB1470:DAY=DAY+1:PRINT"[147]":GOTO870
  94. 1220 REM
  95. 1230 IFCASH>=0ANDWEEK>1THEN1260
  96. 1240 IFLEN(A$)>1ANDWEEK=2ANDCASH<0THEN1260
  97. 1250 IFCASH<0ANDWEEK<>1THEN2720
  98. 1260 FLAG=0:FORB=1TOSKS:IFTABLE(B,1)>0THENFLAG=B
  99. 1270 NEXTB:IFFLAG=0THEN2850
  100. 1280 FLAG=0:IFCASH<=0ANDASSETS<=0THEN2780
  101. 1290 RETURN
  102. 1300 REM MARKET FIGURES
  103. 1310 ASSETS=0:FORA=1TOSKS:IFTABLE(A,1)<=0THEN1400
  104. 1320 CHANGE=TABLE(A,5)+INT(RND(1)*3)-1:IFRND(1)>.85THEN1360
  105. 1330 IFCHANGE>2THENCHANGE=2
  106. 1340 IFCHANGE<-2THENCHANGE=-2
  107. 1350 GOTO1370
  108. 1360 CHANGE=TABLE(A,5)+INT(RND(1)*5)-2
  109. 1370 IFRND(1)>.9THENCHANGE=-1*CHANGE
  110. 1380 TABLE(A,5)=CHANGE:CHANGE=CHANGE+MARKET:TABLE(A,1)=TABLE(A,1)+CHANGE
  111. 1385 IFTABLE(A,1)<=0THEN1410
  112. 1390 TABLE(A,2)=CHANGE:TABLE(A,4)=TABLE(A,3)*TABLE(A,1)
  113. 1400 ASSETS=ASSETS+TABLE(A,4):NEXTA:GOSUB1220:RETURN
  114. 1410 FORB=1TO5:TABLE(A,B)=0:NEXTB:GOTO1400
  115. 1420 REM FIRST OR WEEK
  116. 1430 IFWEEK<>1ANDNOT(WEEK=2ANDLEN(A$)>1)THENRETURN
  117. 1440 BEGINC=0:ASSETS=0:FORB=1TOSKS:IFTABLE(B,1)<=0THEN1460
  118. 1450 ASSETS=ASSETS+TABLE(B,4)
  119. 1460 NEXTB:BEGINC=CASH+ASSETS:GOSUB1220:RETURN
  120. 1470 REM WEEKEND DATA
  121. 1480 INCOME=0:PRINT"[147]":FORA=1TOSKS
  122. 1490 INCOME=INCOME+(TABLE(A,1)*TABLE(A,3))
  123. 1500 NEXTA:PRINTTAB(3)"TOTAL INCOME FOR THE WEEK: ":PRINT
  124. 1510 PRINTTAB(5)"CASH AT WEEKEND:";TAB(27)"$";CASH:PRINTTAB(5)"CURRENT PAPER WORTH:";
  125. 1515 PRINTTAB(27);"$";INCOME
  126. 1520 PRINTTAB(27);"---------":PRINTTAB(5);"TOTAL:";TAB(27);"$";CASH+INCOME:PRINT
  127. 1530 PRINTTAB(5);"TOTAL ASSETS + CASH":PRINTTAB(5);"AT BEGINNING OF WEEK:";TAB(27)"$";
  128. 1535 PRINTBEGINC:PRINTTAB(27)"---------"
  129. 1540 PRINTTAB(5)"GROSS WEEK'S INCOME:";TAB(27);"$";(CASH+INCOME)-BEGINC:PRINTTAB(5);
  130. 1545 PRINT"LESS BROKER'S FEES";TAB(27);"$";FEES
  131. 1550 PRINT:PRINT:PRINTTAB(5);"NET WEEK'S INCOME:";TAB(27);"$";((CASH+INCOME)-BEGINC)-FEES
  132. 1555 PRINT:CASH=CASH-FEES:IFCASH>=0THEN1570
  133. 1560 PRINT"YOU HAVE UNTIL MONDAY TO BREAK":PRINT"EVEN, OR ELSE!!!  (CASH: $";CASH;")"
  134. 1570 BEGINC=CASH+INCOME:FEES=0
  135. 1580 PRINT"PRESS ANY KEY TO CONTINUE...":GOSUB2620:RETURN
  136. 1590 REM ASSET PRINTOUT
  137. 1600 ASSETS=0:FORB=1TOSKS:TABLE(B,4)=TABLE(B,1)*TABLE(B,3)
  138. 1605 ASSETS=ASSETS+TABLE(B,4):NEXTB
  139. 1610 PRINT"CASH: $";CASH;TAB(23);"ASSETS: $";ASSETS
  140. 1620 PRINT:RETURN
  141. 1630 REM DATA PRINTOUT
  142. 1640 REM
  143. 1650 GOSUB4500
  144. 1651 PRINT"" TAB(3);"                                                      "
  145. 1652 PRINT"" TAB(3);"DATE:";DAY$(WEEK);",";MOTH$(MOTH);" ";DAY;",";YEAR
  146. 1660 GOSUB1220:PRINTTAB(40):LTH=FRE(0):RETURN
  147. 1670 REM DIVIDENDS PAID
  148. 1680 CASH=CASH+INT(ASSETS*.08):RETURN
  149. 1690 REM STOCK PRINTOUT
  150. 1700 CHANGE$=STR$(TABLE(A,2)):IFTABLE(A,1)<=0THEN1730
  151. 1710 IFTABLE(A,2)>0THENCHANGE$="+"+STR$(TABLE(A,2))
  152. 1720 PRINTNAME$(A);TAB(16);TABLE(A,1);TAB(21);CHANGE$;TAB(25);TABLE(A,3);
  153. 1725 PRINTTAB(30);TABLE(A,4):GOTO1740
  154. 1730 PRINT"*** ";NAME$(A);" IS BAKNRUPT...";TAB(40)
  155. 1740 RETURN
  156. 1750 REM PRINTOUT ALL
  157. 1760 WAS=AVERAGE:AVERAGE=0:
  158. 1770 PRINT"STOCK NAME";TAB(15);"CLOSE";TAB(21);"CHG";TAB(25);"OWNED";" WORTH"
  159. 1780 FORA=1TO40:PRINT"=";:NEXTA:PRINT
  160. 1790 FORA=1TOSKS:GOSUB 1690
  161. 1800 AVERAGE=AVERAGE+TABLE(A,1):NEXTA
  162. 1810 FORA=1TO40:PRINT"=";:NEXTA:PRINT
  163. 1820 AVERAGE=INT((AVERAGE/SKS)*100)/100
  164. 1830 PRINT"AVERAGE: $";AVERAGE;"/SHARE";TAB(20);
  165. 1840 CHANGE=INT((AVERAGE*100)-(WAS*100))/100
  166. 1850 IFCHANGE<>0THEN1870
  167. 1860 PRINT"(NO CHANGE)":GOTO1900
  168. 1870 IFCHANGE>0THEN1890
  169. 1880 PRINT"(DOWN ";ABS(CHANGE);")":GOTO1900
  170. 1890 PRINT"(UP";ABS(CHANGE);")"
  171. 1900 RETURN
  172. 1901 CHECK=1
  173. 1910 REMDATA INPUT
  174. 1920 REM OPTION INPUT
  175. 1930 FORX=1784+40TO2023:POKEX,32:NEXT:
  176. 1934 GOSUB1590:PRINT"(B)-BUY";TAB(20);
  177. 1935 PRINT"(S)-SELL)
  178. 1940 [153]"(E)-STOP";[163]20);"(RETURN)-PASS":[153]"WHICH FUNCTION DO YOU WANT?":[141]2620
  179. 1950 [139]KEY[178]194[176]KEY[178]211[176]KEY[178]197[176]KEY[178]141[167][142]
  180. 1960 [137]1930:[153]"WHAT????WAIT":[129]B[178]1[164]1000:[130]:[137]1930
  181. 1970 [143] STOCK INPUT
  182. 1980 [129]X[178]1784[171]40[164]2023:[151]X,32:[130]
  183. 1989 [133]"INPUT STOCK NAME: ";IN$
  184. 1990 FLAG[178]0:CHECK$[178][200](IN$,3):[129]A[178]1[164]SKS
  185. 2000 [139]CHECK$[178][200](NAME$(A),3)[167]FLAG[178]A
  186. 2010 [130]A:[139]FLAG[179][177]0[167]2050
  187. 2020 [153]IN$;"???":[129]B[178]1[164]1000:[130]
  188. 2030 [153]"THERE IS NO STOCK BY THAT NAME!!!":[129]B[178]1[164](1.5[172]1000):[