8-Bit Software Online Conversion

4.99p - Listing

10REM" BEWARE!! " Don't renumber - th is confuses calculated GOTOs. 20REM Program to find number of combi nations of coins possible to make £4-99. 30REM J.Davis '94. 40REM Program calculates all 5's, 2's , and 1's at one go after each new 10 or larger. 100MODE7:VDU23,1,0,0;0;0;0; 110PRINTTAB(9);CHR$(141);CHR$(131);"£4 -99 COMBINATIONS" 120PRINTTAB(9);CHR$(141);CHR$(131);"£4 -99 COMBINATIONS" 130PRINTCHR$(145);STRING$(39,"s") 140PRINT" This is a sit-back-and-wat ch-gosh- isn't-it-time-for-a-cup-of-t ea-yet-or- maybe-something-stronger typ e of program." 150PRINT" Once upon a time I was exp ecting a COD delivery of unknown amou nt and wondered if I had the right coins to make any amount between 1p a nd £4-99." 160PRINT" This was easy to arrange. Th en, for no very good reason, I wondered how many different ways there were to make exactly £4-99. That's what t his program works out." 170PRINT" The first combination is a ll pennies, the second is 1x2p and 497x1 p, the third is 2x2p and 495x1p etc ., to a final pattern of 4x100p, 1x5 0p, 2x20p, 1x5p, and 2x2p." 180PRINTTAB(27);"PRESS SPACE" 190PRINTCHR$(145);STRING$(39,"s"); 200G=GET:CLS 210PRINTCHR$(145);STRING$(39,"s") 220PRINT" The first version of this program, where the computer counted e ach combination on its fingers, took a day and a half to run. This fina l version is much quicker, and display s what it's doing as it runs." 230PRINT" For each new pattern of 10' s, 20's, 50's, and 100's, as displaye d, it calculates, with a curious l oop, all the possible combinations of 1's, 2's, and 5's to make £4-99."; 240PRINT" This gives the increase of each new 'Total So Far'." 250PRINT" There may be a formula to calculate the result instantly, but th at would spoil the fun!" 260PRINT" Try to guess the result - very roughly - before running the program. A guess within +/-25% is ver y good." 270PRINT:PRINTTAB(26);"PRESS SPACE" 280PRINTCHR$(145);STRING$(39,"s"); 290G=GET 400CLS 410PRINTTAB(0,10);CHR$(145);STRING$(39 ,"s") 420PRINTTAB(9);CHR$(141);CHR$(131);"£4 -99 COMBINATIONS" 430PRINTTAB(9);CHR$(141);CHR$(131);"£4 -99 COMBINATIONS" 440PRINT 450PRINTCHR$(145);STRING$(39,"s") 500: 510TIME=0 520DIMA(10) 530DIMB(100) 540A(1)=1:A(2)=2:A(3)=5:A(4)=10:A(5)=2 0:A(6)=50:A(7)=100 550F=1:BT=0 560C=0:CA=0 570VDU15 580GOTO2000 590BT=0:F=0 600F=F+1 610IFB(F)=A(G) THEN GOTO G*1000 620BT=BT+B(F) 630GOTO600 1990REM Calculates 1's, 2's, and 5's. 2000CA=CA+1 2010L=(500-BT)/5 2020X=(-1) 2030 M=2:N=0:P=0 2040FORK=1TOL 2050X=X*(-1) 2060M=M+X 2070N=N+M 2080P=P+N 2090NEXT 2100C=C+P 2110PROCprint 2120B(F)=5 2130G=3 2140GOTO590 2990REM Adds 10's, 20's, 50's, & 100's 3000B(F)=10 3010BT=BT+10 3020IFBT>499THENG=4:GOTO590 3030B(F+1)=2 3040G=2 3050GOTO600 4000B(F)=20 4010BT=BT+20 4020IFBT>499THENG=5:GOTO590 4030B(F+1)=2 4040G=2 4050GOTO600 5000B(F)=50 5010BT=BT+50 5020IFBT>499THENG=6:GOTO590 5030B(F+1)=2 5040G=2 5050GOTO600 6000B(F)=100 6010BT=BT+100 6020IFBT>499 THEN PROCend:PROCtime:G=GE T:VDU23,1,1,0;0;0;0;:END 6030B(F+1)=2 6040G=2 6050GOTO600 13990: 14000DEFPROCprint 14010PRINT" ";CA 14020FORK=1TOF-1 14030PRINTB(K); 14040NEXT 14050PRINT:PRINT 14055: 14060PROCcommas 14070PRINTCHR$(141);CHR$(129);"TOTAL SO FAR=";CHR$(131);TA$ 14080PRINTCHR$(141);CHR$(129);"TOTAL SO FAR=";CHR$(131);TA$ 14090PRINT 14100PRINTCHR$(148);STRING$(39,"s") 14110ENDPROC 14990: 15000DEFPROCtime 15010T=INT(TIME/100) 15020PRINT:PRINT 15030PRINTCHR$(134);" TIME= ";(T)DIV60;" min ";(T)MOD60;"sec" 15040PRINTCHR$(145);STRING$(39,"s") 15050VDU7 15060ENDPROC 15065: 15070DEFPROCend 15080PROCcommas 15090PRINTCHR$(141);CHR$(129);"WHEW!!" 15100PRINTCHR$(141);CHR$(129);"WHEW!!" 15110PRINT 15120PRINTCHR$(141);CHR$(131);"GRAND TOT AL= ";TA$;" COMBINATIONS" 15130PRINTCHR$(141);CHR$(131);"GRAND TOT AL= ";TA$;" COMBINATIONS" 15140PRINT:PRINT" Not a lot of people k now that." 15150ENDPROC 15155: 15160DEFPROCcommas 15165TA$="" 15170T$=STR$(C) 15180L=LEN(T$)-3 15190FORN=1TOL 15200TA$=TA$+MID$(T$,N,1) 15210IF(L-N)MOD3=0 THEN TA$=TA$+"," 15220NEXT 15225TA$=TA$+RIGHT$(T$,3) 15230ENDPROC