home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Brotikasten
/
BROTCD01.iso
/
lern
/
lern451.d64
/
stock.c
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
1995-08-09
|
10KB
|
304 lines
1 REM BY MIKE FLAVEL
2 REM REVISED FROM APPLE VERSION
10 C=0:D=0:A=0:ASSETS=0:B=0:BEGINC=10000:BUY=0:WAS=0:BROKER=0
20 CASH=10000:CHANGE=0:DAY=0:FEES=0:FLAG=0:INCOME=0:KEY=0:LAST=0
30 MARKET=-1:MOTH=0:PRICE=0:SELL=0:SHARES=0:QUARTER=0
40 SKS=12:IME=1000:WEEK=0:YEAR=1979:AVERAGE=0:E=0:F=0:G=0:H=0
50 DIMNAME$(SKS),DAY$(5),MOTH$(12),TABLE(SKS,5)
60 DISK$="":A$="":CHANGE$="":CHECK$="":IN$=""
70 NAME$(1)="ALCOA ALUMINUM":NAME$(2)="COMMODORE":NAME$(3)="CBS INDUSTRIES"
80 NAME$(4)="EXXON OIL":NAME$(5)="GENERAL MOTORS":NAME$(6)="HONEYWELL CORP."
90 NAME$(7)="IBM CORPORATION":NAME$(8)="INTEL CORP.":NAME$(9)="LOCKHEED CORP."
100 NAME$(10)="MOTOROLA":NAME$(11)="STANDARD OIL":NAME$(12)="3-M CORPORATION"
110 FORA=1TOSKS:FORB=1TO4:TABLE(A,B)=0:NEXTB,A
120 PRINT"[147]********************":
121 PRINTTAB(10)"** MARKET CRASH **"
130 PRINTTAB(10)"** BY MIKE FLAVEL **":PRINTTAB(10);"********************"
140 FORA=1TOSKS:PRICE=INT(RND(1)*100+1)+20:WAS=WAS+PRICE:TABLE(A,1)=PRICE
150 CHANGE=INT(RND(1)*5)-2:TABLE(A,5)=CHANGE
160 NEXTA:WAS=INT(WAS/SKS*100)/100:AVERAGE=WAS
170 MOTH$(1)="JANUARY":MOTH$(2)="FEBRUARY":MOTH$(3)="MARCH"
180 MOTH$(4)="APRIL":MOTH$(5)="MAY":MOTH$(6)="JUNE"
190 MOTH$(7)="JULY":MOTH$(8)="AUGUST":MOTH$(9)="SEPTEMBER"
200 MOTH$(10)="OCTOBER":MOTH$(11)="NOVEMBER":MOTH$(12)="DECEMBER"
210 DAY$(1)="MONDAY":DAY$(2)="TUESDAY":DAY$(3)="WEDNESDAY":DAY$(4)="THURSDAY"
215 DAY$(5)="FRIDAY"
220 WEEK=0:DAY=0:MOTH=1:LAST=31:QUARTER=0
225 INPUT" DEUTSCHE ANLEITUNG J/N";DE$
226 IF DE$="J"THEN GOSUB 4600:GOTO330
230 PRINT"[147]DO YOU WANT INSTRUCTIONS? Y/N":GOSUB2620:IFKEY=206THEN650
240 PRINT"[147]";TAB(10)"INSTRUCTIONS[146]"
250 PRINT" THIS IS A SIMULATION OF THE OPERATIONS OF THE STOCK MARKET.THERE ARE";
260 PRINT" 12 COMPANY STOCKS AVAILABLE FOR TRADE"
270 PRINT"PROVIDING YOU HAVE THE MONEY, THERE IS A BROKERS FEE OF 6% OR $50.00 PER";
280 PRINT"STOCK. TRANSACTIONS ARE COLLECTED AT THE END OF EACH WEEK"
290 PRINT"HERE ARE THE KEY FUNCTIONS:"
300 PRINT"(S) SELL STOCK":PRINT"(B) BUY STOCK":PRINT"(RETURN) PASS":PRINT"(E) END GAME"
310 PRINT"WHEN BUYING OR SELLING STOCK ENTER AT LEAST THE FIRST THREE INITIALS "
320 PRINT"OF THE STOCK NAME"
330 PRINT"PRESS ANY KEY TO CONTINUE"
340 GOSUB2620:IFKEY=195THEN2560
650 REM
700 REM MAIN PROGRAM
710 GOSUB830
720 GOSUB1300
730 GOSUB1750
740 GOSUB1910
750 IFKEY=194ORKEY=211THEN780
760 IFKEY=197THEN2360
770 GOTO700
780 GOSUB1970
790 IFKEY=194THENGOSUB2070
800 IFKEY=211THENGOSUB2210
810 GOSUB1910
820 GOTO750
830 REM DATA FIGURES
840 MARKET=MARKET+INT(RND(1)*3)-1:IFMARKEY>2THENMARKEY=2
850 IFMARKET<-3THENMARKET=-3
860 IFRND(1)>.92THENMARKET=-1*MARKET
870 FLAG=0:WEEK=WEEK+1:DAY=DAY+1:IFDAY<=LASTTHEN910
880 DAY=DAY-LAST:MOTH=MOTH+1:IFMOTH>12THEN2890
890 QUARTER=QUARTER+1:IFQUARTER<>3THEN910
900 QUARTER=0:GOSUB1670
910 IFWEEK<=5THEN950
920 PRINT"[147]":LAST=28:IFMOTH=4ORMOTH=6ORMOTH=9ORMOTH=11THENLAST=30
930 IFMOTH=1ORMOTH=3ORMOTH=5ORMOTH=7ORMOTH=8ORMOTH=10ORMOTH=12THENLAST=31
940 FLAG=1:WEEK=0:A$="":GOTO1200
950 GOSUB1630:IFMOTH=1ANDDAY=1THEN1060
960 IF MOTH=2ANDDAY=12THENGOTO1070
970 IFMOTH=2ANDDAY=19THENGOTO1080
980 IFMOTH=5ANDDAY=28THENGOTO1090
990 IFMOTH=7ANDDAY=4THENGOTO1100
1000 IFMOTH=9ANDDAY=3THENGOTO1110
1010 IFMOTH=10ANDDAY=8THENGOTO1120
1020 IFMOTH=11ANDDAY=12THENGOTO1130
1030 IFMOTH=11ANDDAY=22THENGOTO1140
1040 IFMOTH=12ANDDAY=25THENGOTO1150
1050 GOTO1190
1060 A$="[147]NEW YEAR'S DAY":GOTO1160
1070 A$="[147]LINCOLN'S BIRTHDAY":GOTO1160
1080 A$="[147]WASHINGTON'S BIRTHDAY":GOTO1160
1090 A$="[147]MEMORIAL DAY":GOTO1160
1100 A$="[147]INDEPENDENCE DAY":GOTO1160
1110 A$="[147]LABOR DAY":GOTO1160
1120 A$="[147]COLUMBUS DAY":GOTO1160
1130 A$="[147]VETERANS DAY":GOTO1160
1140 A$="[147]THANKSGIVING DAY":GOTO1160
1150 A$="[147]CHRISTMAS"
1160 PRINTA$:FORA=1TO1000:NEXTA
1170 PRINTTAB(9)"STOCK MARKET CLOSED...":FORA=1TO1000:NEXTA:PRINT"[147]"
1180 GOTO870
1190 GOSUB1420:IFFLAG=0THENRETURN
1200 PRINTTAB(3)"WEEKEND":PRINTTAB(9)"STOCK MARKET CLOSED..."
1210 PRINT:PRINT:GOSUB1470:DAY=DAY+1:PRINT"[147]":GOTO870
1220 REM
1230 IFCASH>=0ANDWEEK>1THEN1260
1240 IFLEN(A$)>1ANDWEEK=2ANDCASH<0THEN1260
1250 IFCASH<0ANDWEEK<>1THEN2720
1260 FLAG=0:FORB=1TOSKS:IFTABLE(B,1)>0THENFLAG=B
1270 NEXTB:IFFLAG=0THEN2850
1280 FLAG=0:IFCASH<=0ANDASSETS<=0THEN2780
1290 RETURN
1300 REM MARKET FIGURES
1310 ASSETS=0:FORA=1TOSKS:IFTABLE(A,1)<=0THEN1400
1320 CHANGE=TABLE(A,5)+INT(RND(1)*3)-1:IFRND(1)>.85THEN1360
1330 IFCHANGE>2THENCHANGE=2
1340 IFCHANGE<-2THENCHANGE=-2
1350 GOTO1370
1360 CHANGE=TABLE(A,5)+INT(RND(1)*5)-2
1370 IFRND(1)>.9THENCHANGE=-1*CHANGE
1380 TABLE(A,5)=CHANGE:CHANGE=CHANGE+MARKET:TABLE(A,1)=TABLE(A,1)+CHANGE
1385 IFTABLE(A,1)<=0THEN1410
1390 TABLE(A,2)=CHANGE:TABLE(A,4)=TABLE(A,3)*TABLE(A,1)
1400 ASSETS=ASSETS+TABLE(A,4):NEXTA:GOSUB1220:RETURN
1410 FORB=1TO5:TABLE(A,B)=0:NEXTB:GOTO1400
1420 REM FIRST OR WEEK
1430 IFWEEK<>1ANDNOT(WEEK=2ANDLEN(A$)>1)THENRETURN
1440 BEGINC=0:ASSETS=0:FORB=1TOSKS:IFTABLE(B,1)<=0THEN1460
1450 ASSETS=ASSETS+TABLE(B,4)
1460 NEXTB:BEGINC=CASH+ASSETS:GOSUB1220:RETURN
1470 REM WEEKEND DATA
1480 INCOME=0:PRINT"[147]":FORA=1TOSKS
1490 INCOME=INCOME+(TABLE(A,1)*TABLE(A,3))
1500 NEXTA:PRINTTAB(3)"TOTAL INCOME FOR THE WEEK: ":PRINT
1510 PRINTTAB(5)"CASH AT WEEKEND:";TAB(27)"$";CASH:PRINTTAB(5)"CURRENT PAPER WORTH:";
1515 PRINTTAB(27);"$";INCOME
1520 PRINTTAB(27);"---------":PRINTTAB(5);"TOTAL:";TAB(27);"$";CASH+INCOME:PRINT
1530 PRINTTAB(5);"TOTAL ASSETS + CASH":PRINTTAB(5);"AT BEGINNING OF WEEK:";TAB(27)"$";
1535 PRINTBEGINC:PRINTTAB(27)"---------"
1540 PRINTTAB(5)"GROSS WEEK'S INCOME:";TAB(27);"$";(CASH+INCOME)-BEGINC:PRINTTAB(5);
1545 PRINT"LESS BROKER'S FEES";TAB(27);"$";FEES
1550 PRINT:PRINT:PRINTTAB(5);"NET WEEK'S INCOME:";TAB(27);"$";((CASH+INCOME)-BEGINC)-FEES
1555 PRINT:CASH=CASH-FEES:IFCASH>=0THEN1570
1560 PRINT"YOU HAVE UNTIL MONDAY TO BREAK":PRINT"EVEN, OR ELSE!!! (CASH: $";CASH;")"
1570 BEGINC=CASH+INCOME:FEES=0
1580 PRINT"PRESS ANY KEY TO CONTINUE...":GOSUB2620:RETURN
1590 REM ASSET PRINTOUT
1600 ASSETS=0:FORB=1TOSKS:TABLE(B,4)=TABLE(B,1)*TABLE(B,3)
1605 ASSETS=ASSETS+TABLE(B,4):NEXTB
1610 PRINT"CASH: $";CASH;TAB(23);"ASSETS: $";ASSETS
1620 PRINT:RETURN
1630 REM DATA PRINTOUT
1640 REM
1650 GOSUB4500
1651 PRINT"" TAB(3);" "
1652 PRINT"" TAB(3);"DATE:";DAY$(WEEK);",";MOTH$(MOTH);" ";DAY;",";YEAR
1660 GOSUB1220:PRINTTAB(40):LTH=FRE(0):RETURN
1670 REM DIVIDENDS PAID
1680 CASH=CASH+INT(ASSETS*.08):RETURN
1690 REM STOCK PRINTOUT
1700 CHANGE$=STR$(TABLE(A,2)):IFTABLE(A,1)<=0THEN1730
1710 IFTABLE(A,2)>0THENCHANGE$="+"+STR$(TABLE(A,2))
1720 PRINTNAME$(A);TAB(16);TABLE(A,1);TAB(21);CHANGE$;TAB(25);TABLE(A,3);
1725 PRINTTAB(30);TABLE(A,4):GOTO1740
1730 PRINT"*** ";NAME$(A);" IS BAKNRUPT...";TAB(40)
1740 RETURN
1750 REM PRINTOUT ALL
1760 WAS=AVERAGE:AVERAGE=0:
1770 PRINT"STOCK NAME";TAB(15);"CLOSE";TAB(21);"CHG";TAB(25);"OWNED";" WORTH"
1780 FORA=1TO40:PRINT"=";:NEXTA:PRINT
1790 FORA=1TOSKS:GOSUB 1690
1800 AVERAGE=AVERAGE+TABLE(A,1):NEXTA
1810 FORA=1TO40:PRINT"=";:NEXTA:PRINT
1820 AVERAGE=INT((AVERAGE/SKS)*100)/100
1830 PRINT"AVERAGE: $";AVERAGE;"/SHARE";TAB(20);
1840 CHANGE=INT((AVERAGE*100)-(WAS*100))/100
1850 IFCHANGE<>0THEN1870
1860 PRINT"(NO CHANGE)":GOTO1900
1870 IFCHANGE>0THEN1890
1880 PRINT"(DOWN ";ABS(CHANGE);")":GOTO1900
1890 PRINT"(UP";ABS(CHANGE);")"
1900 RETURN
1901 CHECK=1
1910 REMDATA INPUT
1920 REM OPTION INPUT
1930 FORX=1784+40TO2023:POKEX,32:NEXT:
1934 GOSUB1590:PRINT"(B)-BUY";TAB(20);
1935 PRINT"(S)-SELL)
1940 [153]"(E)-STOP";[163]20);"(RETURN)-PASS":[153]"WHICH FUNCTION DO YOU WANT?":[141]2620
1950 [139]KEY[178]194[176]KEY[178]211[176]KEY[178]197[176]KEY[178]141[167][142]
1960 [137]1930:[153]"WHAT????WAIT":[129]B[178]1[164]1000:[130]:[137]1930
1970 [143] STOCK INPUT
1980 [129]X[178]1784[171]40[164]2023:[151]X,32:[130]
1989 [133]"INPUT STOCK NAME: ";IN$
1990 FLAG[178]0:CHECK$[178][200](IN$,3):[129]A[178]1[164]SKS
2000 [139]CHECK$[178][200](NAME$(A),3)[167]FLAG[178]A
2010 [130]A:[139]FLAG[179][177]0[167]2050
2020 [153]IN$;"???":[129]B[178]1[164]1000:[130]
2030 [153]"THERE IS NO STOCK BY THAT NAME!!!":[129]B[178]1[164](1.5[172]1000):[