Page 1 of 1

Carcharge wont print :(

Posted: Tue Dec 13, 2016 2:28 am
by azure8bit
Im having trouble getting CarCharge to print out. If someone could help me. I would appreciate it.

Code: Select all

'*************************** PROGRAM VARIABLES *****************************
CLS
GOSUB InitializeVariables
GOSUB PrintHeadings
GOSUB ProcessDetail
END
'***************************** INITIALIZE VARIABLES *************************

InitializeVariables:
H1$ = " [CUSTOMER NAME]     [CAR TYPE]     [DAYS HELD]     [MILES TRAVELED] [CHARGE]  "
D1$ = " [\      \]          [\          \]    [##]         [#,###]     [####]  "
t1$ = "                      [AUTO RENTAL COMPANY] "
return
'**************************** PRINT HEADINGS ********************************
PrintHeadings:
print
print
print
print t1$
print
print
print h1$
print
RETURN
'*************************** PROCESS DETAIL *********************************
ProcessDetail:
GOSUB ReadData
DO UNTIL UCASE$(NAM$) = "END"
    gosub calculateanswer
    GOSUB PrintDetail
    GOSUB ReadData
LOOP
RETURN
'******************************* CALCULATE ANSWER ****************************
CalculateAnswer:
If Cartype$ = "Compact" then
    CARCHARGE = (10 * DAYS) + (.15 * MILES)
    elseif Cartype$ = "Intermediate" then
    CARCHARGE = (20 * DAYS) + (.18 * MILES)
    elseif Cartype$ = "Large" then
    CARCHARGE = (30 * DAYS) + (.22 * MILES)
end if
return
'******************************* PRINT DETAIL ********************************
PrintDetail:
PRINT USING D1$;NAM$,CarType$,Days,Miles,CarCharge
RETURN
'******************************* READ DATA ***********************************
ReadData:
READ NAM$,CARTYPE$,DAYS,MILES,Carcharge
DATA JONES,LARGE,6,500,0
DATA SMITH,COMPACT,17,3000,0
DATA BAKER,INTERMEDIATE,8,250,0
DATA WILLIAMS,INTERMEDIATE,4,1000,0
DATA WINSTON,LARGE,3,500,0
data end,end,0,0,0
RETURN
'****************************** END OF PROGRAM ***********************************



Re: Carcharge wont print :(

Posted: Sun Dec 18, 2016 8:23 pm
by seaBiscuit!
Take a look in your CalculateAnswer subroutine. That's where your problem is.

What happens if the Cartype$ variable isn't one of the three options?

What is the value of the Cartype$ variable going into that sub?

Answer those two questions, and you'll have your bugfix! :)