REM REM Date REM Instructor Name REM Assignment Chapter 1 Number 8 Page 30 REM REM Statement of problem : create invoice for car rental agency REM Analysis IPO. REM REM Data Requirements REM REM Constants none REM REM Inputs firstname$, lastname$, nodays, odemeterbeg, odemeterend REM rentalrate, milagerate, address$, city$,state$,zip$ REM REM Outputs car rental agency invoice for car rental REM REM Variables totalsumcost, totalmilecost, totaldaycost, REM firstname$,lastname$, address$,city$,state$,zip$, odemeterbeg, REM nodays, odmenterend,rentalrate, milagerate REM REM Formulas totalmiles =odmenterend-odementerbeg REM totalmilecost=totalmiles*milagerate REM totaldaycost=nodays*rentalrate REM totalsumcost= totalmilecost + totaldaycost REM REM REM Design REM REM Algorithm REM REM 1. REM 2. REM 3. REM 4. Etc. REM REM Implementation - here you begin to code. REM Main Program CLS looper$ = " " DO WHILE looper$ <> "QUIT" REM GOSUB caculatesummary GOSUB initilizevar GOSUB carmenu CLS REM GOSUB inputdata REM GOSUB processdata REM GOSUB outputdata INPUT "To enter another customer touch enter, else type QUIT and then touch enter"; looper$ looper$ = UCASE$(looper$) LOOP END REM Subrountines initilizevar: ssn$ = " " ' indiviual customer number ssn1$ = " " ' used for selection statement in processing section firstname$ = " " lastname$ = " " city$ = " " state$ = " " zip$ = " " nodays = 0 totalmiles = 0 totalmilecost = 0 totaldaycost = 0 totalsumcost = 0 milagerate = 0 odemeterend = 0 odmenterbeg = 0 rentalrate = 0 nomiles = 0 RETURN REM Input Section inputdata: OPEN "a:\carinvoi.txt" FOR APPEND AS #1 DO WHILE looper2$ <> "QUIT" INPUT "What is the customers Social Security Number xxx-xx-xxxx"; ssn$ INPUT "What is the customers first name"; firstname$ INPUT "What is the customers last name"; lastname$ INPUT "What is the customers address"; address$ INPUT "What is the customer City "; city$ INPUT "What is the customer State"; state$ INPUT "What is the customers Zip"; zip$ INPUT "How many day was the car used"; nodays INPUT "What was the beginning odemeter reading"; odmenterbeg INPUT "what was the ending odemeter reading"; odmenterend INPUT "what is the milage rate per mile"; milagerate INPUT "what is the daily rental rate"; rentalrate GOSUB processdata WRITE #1, totalmiles, totalmilecost, totaldaycost, totalsumcost, ssn$, firstname$, lastname$, address$, city$, state$, zip$, nodays, odmenterbeg, odmenteredn, milagerate, rentalrate INPUT "Touch enter to do another customer, else type quit"; looper2$ looper2$ = UCASE$(looper2$) LOOP CLOSE #1 RETURN REM Processing Section processdata: totalmiles = odmenterend - odmenterbeg totalmilecost = totalmiles * milagerate totaldaycost = nodays * rentalrate totalsumcost = totalmilecost + totaldaycost RETURN REM Output Section outputdata: CLS FOR x = 1 TO 80 PRINT "-"; NEXT x PRINT PRINT TAB(31); "Awesome Car Rentals" PRINT TAB(31); "Customer Invoice" PRINT PRINT "SSN "; ssn$ PRINT firstname$; " "; lastname$ PRINT address$ PRINT city$; " "; state$; " "; zip$ PRINT PRINT "Number of days"; TAB(18); "Miles Driven"; TAB(30); "Total Charge" PRINT " "; nodays; TAB(19); totalmiles; TAB(31); PRINT USING "$$###.###.##"; totalsumcost FOR x = 1 TO 80 PRINT "-"; NEXT x RETURN caculatesummary: CLS INPUT "Enter the ssn of customer for summary report"; ssn1$ OPEN "a:\carinvoi.txt" FOR INPUT AS #1 DO WHILE NOT EOF(1) INPUT #1, totalmiles, totalmilecost, totaldaycost, totalsumcost, ssn$, firstname$, lastname$, address$, city$, state$, zip$, nodays, odmenterbeg, odmenteredn, milagerate, rentalrate IF ssn$ = ssn1$ THEN accumtotalcost = accumtotalcost + totalsumcost accumtotalmiles = accumtotalmiles + totalmiles accumtotalnodays = accumtotalnodays + nodays END IF LOOP CLOSE #1 CLS FOR x = 1 TO 80 PRINT "-"; NEXT x PRINT PRINT TAB(31); "Awesome Car Rentals" PRINT TAB(31); "Customer Invoice" PRINT TAB(31); "Summary Report" PRINT PRINT "SSN "; ssn$ PRINT firstname$; " "; lastname$ PRINT address$ PRINT city$; " "; state$; " "; zip$ PRINT PRINT "Total Number of days"; TAB(18); "Total Miles Driven"; TAB(40); "Total Charge" PRINT " "; accumtotalnodays; TAB(19); accumtotalmiles; TAB(41); PRINT USING "$$###.###.##"; accumtotalcost FOR x = 1 TO 80 PRINT "-"; NEXT x INPUT "touch enter to continue"; anykey$ CLS RETURN carmenu: FOR x = 1 TO 80 PRINT "-"; NEXT x PRINT TAB(35); "Car Rental Menu" PRINT PRINT TAB(5); "1. Input customer rental data" PRINT TAB(5); "2. Display summary report" PRINT TAB(5); "3. exit" PRINT FOR x = 1 TO 80 PRINT "-"; NEXT x INPUT "enter your menu choice 1, 2 or 3"; menuchoice SELECT CASE menuchoice CASE IS = 1 GOSUB inputdata CASE IS = 2 GOSUB caculatesummary CASE IS = 3 END END SELECT RETURN