1 CLS:PRINT  TAB(5);"AUTO EXPENSE ANALYSIS":PRINT   
2 PRINT "THIS SIMPLE PROGRAM WILL PERMIT THE INDIVIDUAL TO KEEP A  
3 PRINT "RECORD OF ALL EXPENSES PERTAINING TO THE USE OF AN AUTOMOBILE.  
4  PRINT "FOR EACH EXPENSE THIS PROGRAM STORES THE FOLLOWING:  
5  PRINT "AN EXPENSE TYPE CHOSEN FROM GAS,OIL,MAIN,TOLL,INS,PAYM OR MISC  
6  PRINT "MAIN MEANS MAINTENANCE,INS IS INSURANCE,PAYM IS CAR PAYMENT.  
7  PRINT "IN ADDITION TO TYPE EXPENSE THERE IS DESCRIPTION,DATE,PLACE OF  
8  PRINT "SERVICE,QUANTITY PURCHASED,BILL AMOUNT AND ODOMETER READING.  
9  PRINT "THIS DATA IS STORED IN A FILE IN MEMORY. THIS FILE MAY BE   
10  PRINT "SAVED ON DISKETTE OR CASSETTE AND RECALLED,IT MAY BE EDITED  
11 PRINT "LISTED ON CRT OR PRINTER,ETC. A MILES PER GALLON CALCULATION  
12 PRINT "MAY ALSO BE PERFORMED.  
15 PRINT :INPUT "PRESS ENTER TO BEGIN";Z9$  
50 CLEAR  3000  
60 DIM  AA$(70,4),BB(70,3)  
65 DIM  AT$(70,4),BT(70,3)  
70 GOSUB  9000  
100 ' CLS:INPUT "ARE DISK DRIVES ATTACHED(Y/N)";ZD$  
110 ' IF  ZD$<>"Y"  AND  ZD$<>"N"  THEN  GOSUB  10000:GOTO  100  
120 ZD$ = "Y" ' bwBASIC does not support cassette input
500 CLS:PRINT "       MAIN MENU":PRINT   
505 PRINT " 0.QUIT
510 PRINT " 1.ADD TO FILE OR BEGIN NEW FILE  
520 PRINT " 2.READ FILE IN FROM TAPE  
530 PRINT " 3.WRITE FILE OUT ONTO TAPE  
540 PRINT " 4.READ FILE IN FROM DISK  
550 PRINT " 5.WRITE FILE OUT ONTO DISK  
560 PRINT " 6.EDIT FILE  
570 PRINT " 7.LIST CONTENTS, COMPLETE OR BY TYPE  
580 PRINT " 8.ROUTINE ACTUALLY DELETING RECORD FROM FILE  
590 Z9=0  
600 INPUT "ENTER YOUR CHOICE";Z9  
605 IF Z9 = 0 THEN END
610 ON  Z9 GOSUB  1000,2000,2100,2200,2300,3000,5000,7000  
620 GOTO  500  
1000 REM ADD TO OR START FILE ALREADY IN MEMORY  
1010 CLS: IF  NI=0 THEN PRINT  "NEW FILE":GOSUB  10100  
1013 IF  NI=0  THEN  GOSUB  6500:PRINT "INITIAL ENTRY DONE":GOSUB  10100:CLS  
1015 J=NI+1  
1020 GOSUB 6000:REM INPUT 1 RECORD  
1030 CLS:PRINT F$(2):GOSUB 6100:REM PRINT OUT 1 RECORD  
1040 GOSUB  10200:IF  Z9$="N" THEN GOTO  1020  
1050 IF  Z9$="A" THEN RETURN   
1060 NI=NI+1:REM NEW RECORD ON FILE  
1070 GOSUB 10400:REM MORE?  
1080 IF  Z9$="Y" THEN GOTO  1000 :  ELSE   RETURN   
2000 REM READ IN FILE FROM TAPE  
2010 CLS:PRINT "PUT DATA TAPE IN TAPE DRIVE":GOSUB  10100  
2015 ' IF  ZD$="Y"  THEN  CMD"T"  
2020 INPUT  #-1,NI  
2030 FOR  J=0  TO  NI:INPUT  #-1,AA$(J,1),AA$(J,2),AA$(J,3),AA$(J,4),BB(J,1),BB(J,2),BB(J,3):NEXT   
2040 RETURN   
2100 REM WRITE OUT FILE ONTO TAPE  
2105 CLS  
2110 PRINT "PUT DATA TAPE IN TAPE DRIVE":GOSUB  10100  
2115 ' IF  ZD$="Y"  THEN  CMD"T"  
2130 WRITE  #-1,NI  
2140 FOR  J=0  TO  NI:WRITE  #-1,AA$(J,1),AA$(J,2),AA$(J,3),AA$(J,4),BB(J,1),BB(J,2),BB(J,3):NEXT   
2150 RETURN   
2200 REM READ IN FILE FROM DISK  
2210 CLS:PRINT "PUT DATA DISK IN DISK DRIVE":GOSUB  10100  
2220 ON  ERROR  GOTO  2290  
2225 PRINT :INPUT "ENTER NAME OF FILE TO READ IN";FI$  
2230 OPEN "I",1,FI$  
2240 INPUT  # 1,NI  
2250 FOR  J=0  TO  NI:INPUT  # 1,AA$(J,1),AA$(J,2),AA$(J,3),AA$(J,4),BB(J,1),BB(J,2),BB(J,3):FOR  JJ=1 TO 4:Z8$=AA$(J,JJ):GOSUB  11000:AA$(J,JJ)=Z8$:NEXT  JJ:NEXT   
2260 CLOSE # 1  
2270 RETURN   
2290 PRINT  "FILE DOES NOT EXIST":GOSUB  10100:RETURN   
2300 REM WRITE FILE OUT TO DISK  
2305 CLS  
2310 PRINT :PRINT "PUT DATA DISK IN DISK DRIVE":GOSUB  10100  
2315 PRINT :PRINT "PRESENT DISK FILE IS ";FI$;" ";:INPUT "NEW FILE ";FI$  
2320 OPEN "O",1,FI$  
2330 WRITE  # 1,NI  
2340 FOR  J=0  TO  NI:WRITE  # 1,AA$(J,1),AA$(J,2),AA$(J,3),AA$(J,4),BB(J,1),BB(J,2),BB(J,3):NEXT 
2370 CLOSE # 1  
2380 RETURN   
3000 REM EDIT FILE  
3010 CLS:PRINT "   ";F$(2)  
3020 FOR  J=0 TO NI  
3030 PRINT USING "## ";J;  
3040 GOSUB  6100  
3050 IF  J/12=INT(J/12) THEN GOSUB  4000  
3060 NEXT  J  
3062 J=J-1  
3065 IF  J/12=INT(J/12) THEN GOTO  3080  
3070 GOSUB  4000  
3080 RETURN   
4000 REM EDIT SUBROUTINE  
4010 K=J  
4020 PRINT   
4025 J=0  
4028 PRINT "CHANGE TYPE CODE TO ZZZZ FOR DELETING"  
4030 INPUT "ENTER # OF ITEM YOU WISH TO EDIT,0 IF NONE";J  
4035 IF  J=0  THEN  J=K:RETURN   
4040 CLS:PRINT "   ";F$(2):PRINT   
4050 PRINT "   ";:GOSUB  6100  
4060 PRINT :GOSUB  6000  
4070 CLS:PRINT "   ";F$(2)  
4080 FOR  J=INT(K/12)*12+1  TO  K:PRINT USING "## ";J;:GOSUB 6100:NEXT   
4090 GOTO  4020  
5000 REM LIST FILE WITH ANALYSIS  
5005 INPUT "IS A LINE PRINTER TO BE USED(Y/N)";Z2$:IF  Z2$<>"Y"  AND  Z2$<>"N" THEN GOSUB  10000:GOTO  5005  
5010 CLS:PRINT "           LIST  MENU":PRINT   
5020 PRINT "1. COMPLETE LIST AS ON FILE  
5030 PRINT "2. LIST BY TYPE  
5050 PRINT "3. END LIST PROGRAM  
5060 PRINT :INPUT "ENTER APPROPRIATE CHOICE";Z9  
5065 IF  Z9=3 THEN RETURN   
5070 ON  Z9 GOSUB  5200,5300  
5080 GOTO  5010  
5100 RETURN   
5200 REM COMPLETE LIST  
5205 CLS:IF  Z2$="Y"  THEN  PRINT "PUT PAPER INTO PRINTER":GOSUB  10100  
5210 PRINT  F$(2):IF  Z2$="Y"  THEN  LPRINT  TAB(20);"COMPLETE LIST":LPRINT  F$(5)  
5215 V(1)=0:V(2)=0:V(3)=0:V(4)=0  
5220 FOR  J = 0  TO  NI  
5230 GOSUB 6100:GOSUB 6300:REM 1 RECORD PRINTED  
5233 IF AA$(J,1)="GAS" THEN V(1)=V(1)+BB(J,1):GM=J:OD=BB(J,3) ' REM TOTAL GASOLINE  
5236 V(2)=V(2)+BB(J,2):REM TOTAL COST  
5237 V(3)=OD-BB(0,3):REM TOTAL MILEAGE  
5238 V(4)=BB(GM,3)-BB(0,3):REM TOTAL MILEAGE FOR GASOLINE  
5240 IF  J/12 = INT(J/12) THEN PRINT :GOSUB  10100:CLS:PRINT  F$(2)  
5250 NEXT  J  
5260 PRINT :GOSUB  10100  
5262 PRINT USING  "TOTAL GASOLINE USED     :    #####.##";V(1)  
5264 PRINT USING  "TOTAL MILEAGE GONE      :   ######.##";V(3)  
5265 PRINT USING  "TOTAL COST OF USE       :   $$####.##";V(2)  
5266 PRINT USING  "MILES/GALLON            :      ###.##";V(4)/V(1)  
5267 PRINT USING  "TOTAL COST/MILE         :  $$#####.##";V(2)/V(3)  
5268 IF  Z2$<>"Y"  THEN  GOTO  5280  
5271 LPRINT  " ":LPRINT  " "  
5272 LPRINT  USING  "TOTAL GASOLINE USED     :    #####.##";V(1)  
5274 LPRINT  USING  "TOTAL MILEAGE GONE      :   ######.##";V(3)  
5275 LPRINT  USING  "TOTAL COST OF USE       :   $$####.##";V(2)  
5276 LPRINT  USING  "MILES/GALLON            :      ###.##";V(4)/V(1)  
5277 LPRINT  USING  "TOTAL COST/MILE         :  $$#####.##";V(2)/V(3)  
5280 PRINT :GOSUB  10100:RETURN   
5300 REM LIST TYPE  
5305 CLS:INPUT "ENTER TYPE DESIRED";RM$  
5310 V(1)=0:V(2)=0:V(3)=0:V(4)=0  
5315 CLS:PRINT  @  398,"******* COMPUTING *******"  
5320 FOR  J=0  TO  NI  
5325 IF  RM$<>AA$(J,1)  THEN  GOTO  5390  
5330 V(1)=V(1)+BB(J,2):REM TOTAL COST FOR THIS EXPESE TYPE  
5390 NEXT  J  
5400 CLS:PRINT  F$(2):IF  Z2$="Y"  THEN  LPRINT  TAB(20); "LIST OF TYPE ";RM$:LPRINT  F$(5)  
5405 JJ=0  
5410 FOR  J=0 TO NI  
5415 IF  RM$<>AA$(J,1)  THEN  GOTO  5450  
5417 JJ=JJ+1  
5420 GOSUB  6100  
5430 GOSUB  6300  
5440 IF  JJ/12=INT(JJ/12)  THEN  GOSUB  10100:CLS:PRINT  F$(2):PRINT  F$(6)  
5450 NEXT  J  
5460 PRINT :GOSUB  10100  
5470 PRINT   
5480 PRINT  USING "TOTAL COST FOR THIS EXPENSE TYPE : $$#####.##";V(1)  
5500 IF  Z2$<>"Y"  THEN  GOTO  5550  
5505 LPRINT  " ":LPRINT  " "  
5510 LPRINT USING "TOTAL COST FOR THIS EXPENSE TYPE : $$#####.##";V(1)  
5530 LPRINT :LPRINT   
5550 PRINT :GOSUB  10100:RETURN   
6000 REM SBR FOR INPUTTING DATA ON 1 PURCHASE  
6005 F$(1)="%                        %"  
6008 PRINT "EXPENSE TYPES: GAS  OIL   MAIN  TOLL  INS   PAYM   MISC":PRINT   
6010 PRINT USING F$(1);AA$(J,1),:INPUT "TYPE EXPENSE     ";AA$(J,1)  
6012 A$=AA$(J,1):IF  A$<>"GAS"  AND  A$<>"OIL"  AND  A$<>"MAIN"  AND  A$<>"TOLL"  AND  A$<>"INS"  AND  A$<>"PAYM"  AND  A$<>"MISC"  AND  A$<>"ZZZZ"  THEN  GOSUB  10000:GOTO  6008  
6015 PRINT USING F$(1);AA$(J,2),:INPUT "EXP. DESCRIPTION ";AA$(J,2)  
6020 PRINT USING F$(1);AA$(J,3),:INPUT "DATE OF EXPENSE  ";AA$(J,3)  
6023 PRINT USING F$(1);AA$(J,4),:INPUT "PLACE OF SERVICE ";AA$(J,4)  
6035 F$(1)=" #########.##                "  
6040 PRINT USING F$(1);BB(J,1),:INPUT "QUANT. PURCH   ";BB(J,1)  
6050 PRINT USING F$(1);BB(J,2),:INPUT "BILL AMOUNT    ";BB(J,2)  
6055 PRINT USING F$(1);BB(J,3),:INPUT "ODOMETER READ. ";BB(J,3)  
6099 RETURN   
6100 REM PRINT 1 LINE OF PORTFOLIO  
6110 PRINT   USING  F$(4);AA$(J,1),AA$(J,2),AA$(J,3),AA$(J,4),BB(J,1),BB(J,2),BB(J,3)  
6120 RETURN   
6300 REM PRINT 1 LINE OF PORTFOLIO ON PRINTER  
6310 IF  Z2$<>"Y"  THEN  RETURN   
6320 LPRINT  USING  F$(7);AA$(J,1),AA$(J,2),AA$(J,3),AA$(J,4),BB(J,1),BB(J,2),BB(J,3)  
6330 RETURN   
6500 REM INITIAL INPUT  
6510 CLS  
6520 PRINT "INITIAL INPUT ENTRY"  
6522 PRINT "MAKE THIS ENTRY WITH A FULL GAS TANK":PRINT   
6530 AA$(0,1)="GAS":AA$(0,2)="INITIAL"  
6540 INPUT "ENTER DATE(MM/DD/YY)";AA$(0,3)  
6550 INPUT "ENTER ODOMETER READING";BB(0,3)  
6560 RETURN   
7000 REM DELETE SBR COMPUTATION  
7005 K=1:REM K=NO. OF RECORDS NOT DELETED  
7010 FOR  J=1  TO  NI  
7020 IF  AA$(J,1)="ZZZZ" THEN GOTO  7090  
7030 REM DO NOT DELETE RECORD  
7040 FOR  J6=1 TO 4:AT$(K,J6)=AA$(J,J6):NEXT   
7050 FOR  J6=1 TO 3:BT(K,J6)=BB(J,J6):NEXT   
7060 K=K+1:GOTO 7090  
7090 NEXT  J  
7100 K=K-1:NI=K  
7110 FOR  J=1 TO NI  
7120 FOR  J6=1 TO 4:AA$(J,J6)=AT$(J,J6):NEXT   
7130 FOR  J6=1 TO 3:BB(J,J6)=BT(J,J6):NEXT   
7140 NEXT  J  
7150 RETURN   
9000 REM FORMATTING VARIABLES  
9020 F$(2)="TYPE  DESCRIPT   DATE      PLACE   QUANT.  $ AMT.   ODOMETER"  
9030 F$(4)="%  %  %       % %      %  %     %  ####.#  ####.##  ######.#"  
9040 F$(5)="TYPE  DESCRIPTION     DATE     PLACE    QUANTITY    $ AMT.    ODOMETER"  
9060 F$(7)="%  %  %          %  %      %  %      %    ####.#   $$###.##    ######.#"  
9099 RETURN   
10000 REM INPUT ERROR SBR  
10010 PRINT "INPUT ERROR! TRY AGAIN!":FOR  Z9=1 TO 300:NEXT  Z9  
10020 RETURN   
10100 INPUT "PRESS ENTER TO CONTINUE";Z9:RETURN   
10200 REM Y,N,A SBR  
10205 Z9$=" "  
10210 INPUT "ENTER Y IF OK,N IF ERROR,A TO ABORT";Z9$  
10220 IF  Z9$<>"Y"  AND  Z9$<>"N"  AND  Z9$<>"A" THEN GOSUB  10000:GOTO 10205  
10230 RETURN   
10300 REM Y,N SBR  
10305 Z9$=" "  
10310 INPUT "ENTER Y IF OK, N IF ERROR";Z9$  
10320 IF  Z9$<>"Y"  AND  Z9$<>"N" THEN GOSUB  10000:GOTO  10305  
10330 RETURN   
10400 REM MORE ENTRY? SBR  
10405 Z9$=" "  
10410 INPUT "DO YOU DESIRE MORE ENTRIES(Y/N)";Z9$  
10420 IF  Z9$<>"Y"  AND  Z9$<>"N" THEN GOSUB  10000:GOTO  10405  
10430 RETURN   
10500 REM ONLY Y/N SBR  
10510 IF  Z9$<>"Y"  AND  Z9$<>"N" THEN GOSUB  10000  
10520 RETURN   
11000 REM ELIMINATES TRAILING BLANKS OF VARIABLE Z8$  
11010 IF  RIGHT$(Z8$,1)=" "  THEN  Z8$=LEFT$(Z8$,LEN(Z8$)-1):GOTO  11010  
11020 RETURN   

