home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
mbug
/
mbug086.arc
/
EXCHANGE.BAS
< prev
next >
Wrap
BASIC Source File
|
1979-12-31
|
5KB
|
184 lines
10 rem FOREIGN EXCHANGE
\ By TIM HARTNELL
\ Code converted to CBASIC and compiled with CB80
\ 29/03/1988
restore
dim n$(9), v(9), f(9), u(9), l(9), h(9)
print chr$(26)
print tab(20);"The game of $$ FOREIGN EXCHANGE $$$"
PRINT
print tab(20);"By Tim Hartnell and keyed by A. Barfoot"
print
10.2 print"The object of this game it to turn $1000.00 into $5000.00 in"
print"the least amount of time as possible by buying and selling "
print"foreign currencies. Sales and purchases are in multiples of 10."
print
print"E.G. If you want to buy or sell 100 U.S. DOLLARS, enter 10 "
print"when asked how many you wish to buy or (sell)."
print
print"Each negiotation costs .25 and your CASH attracts .125% interest"
print
print"Apart from that, the least amount of `negotations' the better."
print
print"Good Luck!"
print
print
gosub 1040
print "PRESS ANY KEY TO CONTINUE ";
10.21 fetch=inkey:key$=chr$(fetch):if ucase$(key$) ="" THEN 10.21
20 GOSUB 1040 : print chr$(26)
30 PRINT CHR$(26) : GOSUB 220
40 rem each negotition costs .25
rem cash attracts .125% interest
60 rem per negotation
70 cash = 1.0125 * cash
80 neg = neg + 1 : cash = cash - .25
90 gosub 380
100 if money + cash le 0 or money + cash ge 500 then 130
110 gosub 950
120 goto 30
130 print chr$(26)
print "After ";neg-1;" negotations you have managed to trade your"
print "original $1,000 into $";int((money+cash)*100/10)
160 gosub 1360
170 if money+cash le 0 then \
print "You've not done well in foregin exchange."
goto 190
180 print "You have done well on the foregin exchange."
190 gosub 270
goto 2000
220 PRINT CHR$(26)
240 if health lt 0 then \
print"* Market weak. This is negotation ";neg
250 if health gt 0 then \
print"* Market rallies. This is negotation ";neg
260 print
print"Currency";tab(19);"Rate";tab(26);"Number Value"
270 money = 0
280 for j = 1 to 9
290 print j;left$(n$(j),13);tab(18);sgn(f(j))*int(v(j)*1000)/(1000);
300 if h(j)>0 then \
print tab(25);h(j);tab(32);int(h(j)*v(j)*100)/10
money = money +h(j)*v(j)
310 if h(j) = 0 then \
print
320 next j
330 gosub 1360
340 print"CURR HELD $";INT(100*MONEY)/10;\
TAB(20);"IN HAND $";INT(CASH*100/10);
print tab(20);"TOTAL $";int((money+cash)*100)/10
return
370 rem
380 print"B - Buy, S - Sell, W - Wait, Q - Quit ";
401 fetch=inkey:key$=chr$(fetch)
if ucase$(key$)="Q" then 130
if ucase$(key$)="W" then RETURN
if ucase$(key$)="S" then 700
if ucase$(key$)="B" then 480
GOTO 401
480 PRINT
input"Currency to buy (enter number)";t
randomize
490 if t < 1 or t > 9 then 490
y = t
520 print"You wish to buy ";n$(y)
530 print"Curent price is $";v(y)
540 input"How many do you wish to purchase ";x
550 if x < 1 then 590
x = 10 * x
580 if x*v(y) > cash then \
print"You cannot afford that many!" : gosub 1360 : goto 540
590 cash = cash - x * v(y)
600 h(y) = h(y) + x
610 gosub 220
630 input"Enter number to buy more, 0 to end";t
631 if t < 0 or t > 9 then 631
if t = 0 then return
y = t
680 gosub 220
690 goto 520
700 rem
710 rem
720 print
INPUT"Currency (number) to sell, 0 to end.";r
721 if r < 1 or r > 9 then 721
760 q = r
if q = 0 then return
780 if h(q) = 0 then \
print"You have no ";n$(q) : \
for j = 1 to 700 : next j : gosub 1360 : return
790 print"How many ";n$(q);" to sell ";
input r
r = 10 * r
810 if r > h(q) then \
print"You do not have that many!" : gosub 1360 : goto 790
820 h(q)=h(q) - r
830 cash = cash + v(q) * r
840 gosub 220
850 print
860 INPUT"Enter number to sell more, 0 to end ";T
861 if t < 0 or t > 9 then 861
if t = 0 then return
q = t
920 gosub 220
930 goto 780
950 health = 0
for j = 1 to 9
980 if rnd > .3 then \
v(j) = int((v(j)+f(j))*1000)/1000
990 if v(j) > u(j) or v(j) < l(j) then \
v(j) = v(j) - f(j) /2 : f(j) =-f(j)
1000 health = health + sgn(f(j))
next j
return
1030 rem
1040 restore
1050 \ n$ = currency name
\ v = value (in US $)
\ f = fulctuation rate
\ u = upper limit
\ l = lower limit
\ h = holdings
cash = 100
neg = 1
health = 1
for j = 1 to 9
1180 read n$(j),v(j)
1190 x = rnd
v(j)=v(j) + (x * 10 + 1 ) /100
1200 f(j) = v(J)/9
u(j) = v(j) + 4 * f(j)
l(j) = 4 * f(j)
1230 if rnd > .5 then
f(j) = -f(j)
1240 if l(j) > v(j) then \
l(j) = l(j) - f(j)
next j
1260 return
1270 data "U.S. DOLLAR",1
data "DANISH KRONER",0.1071
data "FRENCH FRANC",0.1267
data "GERMAN MARK",0.3906
data "CHINESE YUAN",0.5181
data "SOUTH AFRICAN RAND",0.8730
data "SWISS FRANC",0.4784
data "SAUDI ARABIAN RYL",0.3039
data "HONG KONG DOLLAR",0.1369
1360 REM line
PRINT"-------------------------------------"
return
goto 30
2000 PRINT
print"Do you want to play again Y/N ?";
fetch=inkey:key$=chr$(fetch):if ucase$(key$)="Y" then \
print chr$(26) : goto 20
stop