Simple type mismatch help =[

February 26, 2011 at 10:26:22
Specs: Macintosh
For some reason I cannot figure out what im doing wrong...Im taking this qBasic class for the first time so this is my first time messing around with it. What im trying to do is make it Print out the names, days, room number and total pay. I feel like im doing the calculations wrong also...Im not that skilled and need some help or some tips!


CLS


'----------------------------------------------------------------------------
' Program Mainline
'----------------------------------------------------------------------------

GOSUB InitializeVariables
GOSUB PrintHeadings
GOSUB ProcessDetail
GOSUB PrintTotals
END

'----------------------------------------------------------------------------
' Initialize Variables
'----------------------------------------------------------------------------

InitializeVariables:
LET T1$ = " Stateside Hospital Report Page##"
LET H1$ = " Person's Number Room Total"
LET H2$ = " Name of days Type Bill"
LET D1$ = " \ \ ### $###,###"
LET St$ = " SubTotal $###,###"
LET Rt$ = " Total Bill $###,###"

RETURN

'----------------------------------------------------------------------------
' Print Headings
'----------------------------------------------------------------------------

PrintHeadings:
LET PageCt = PageCt + 1
PRINT CHR$(12);
PRINT USING T1$; PageCt
PRINT
PRINT
PRINT H1$
PRINT H2$
PRINT
PRINT
LET LineCt = 0
LET Maxlines = 15
RETURN

'----------------------------------------------------------------------------
' Process Details
'----------------------------------------------------------------------------

ProcessDetail:
GOSUB ReadData
DO UNTIL Per$ = "00"
GOSUB CalculateTotal
GOSUB PrintDetails
IF LineCt >= Maxlines THEN
GOSUB PrintHeadings
END IF
GOSUB ReadData
LOOP
RETURN

'----------------------------------------------------------------------------
' Read Data
'----------------------------------------------------------------------------

ReadData:
READ Per$, RoomType$, Days
DATA GREG SCOTT, I, 3
DATA JOHN NELSON, I, 12
DATA SALLY GOLDSMITH, P, 14
DATA CAROL DUNCKON, I, 2
DATA KIM AGNEW, D, 1
DATA TOM JONES, D, 7
DATA RICHARD HERNANDEZ, D, 15
DATA DEON MOORE, I, 18
DATA GAIL KIDD, I, 17
DATA RAY REDSTONE, P, 12
DATA STEVE SILLO, P, 6
DATA SCOTT BROWN, P, 2
DATA PEGGY SMITH, D, 5
DATA SUE JOHNSON, I, 7
DATA MARTHA MILLER, P, 21
DATA JAIME ROBINSON, D, 6
DATA PEARL RUSS, I, 4
DATA DIANE HANLEY, I, 3
DATA MIKE WILLIAMS, D, 19
DATA DUANE NICHOLS, D, 14
DATA 00, 00, 00
RETURN

'----------------------------------------------------------------------------
' Calculate Total
'----------------------------------------------------------------------------

CalculateTotal:

LET Caltot = Caltot + TotalPay

IF RoomType$ = "I" THEN
LET TotalPay = (Days * 355)
ELSEIF RoomType$ = "P" THEN
LET TotalPay = (Days * 275)
ELSEIF RoomType$ = "D" THEN
LET TotalPay = (Days * 150)
END IF

RETURN

'----------------------------------------------------------------------------
' Print Details
'----------------------------------------------------------------------------

PrintDetails:
PRINT USING D1$; Per$; RoomType$; Days; TotalPay;
LET LineCt = LineCt + 1
RETURN

'----------------------------------------------------------------------------
' Print SubTotals
'----------------------------------------------------------------------------

PrintSubTotals:
PRINT
PRINT USING St$; CalSubtot
PRINT
LET Caltot = Caltot + 1
RETURN

'----------------------------------------------------------------------------
' Print Totals
'----------------------------------------------------------------------------

PrintTotals:
PRINT USING Rt$; Caltot
RETURN

'----------------------------------------------------------------------------
' End of Program
'----------------------------------------------------------------------------


See More: Simple type mismatch help =[

Report •


#1
February 27, 2011 at 22:46:56
Anyone? I really need help

Report •

#2
February 28, 2011 at 12:54:07
Hi
Its a long time since I did any Basic programming.
What output do you get if any.
It may be the gosub ReadData thats causing problems.
try changing "Gosub ReadData" to "READ Per$, RoomType$, Days"
and delete it or just Rem it out it subroutine "ReadData"
From what I remember when reading Data statements a pointer
is set at the next read statement, so maybe the gosub is upsetting
this.
------------------------------------------------------------------------------------------------

ProcessDetail:
READ Per$, RoomType$, Days
DO UNTIL Per$ = "00"
GOSUB CalculateTotal
READ Per$, RoomType$, Days
IF LineCt >= Maxlines THEN
GOSUB PrintHeadings
END IF
READ Per$, RoomType$, Days
LOOP
RETURN


Report •
Related Solutions


Ask Question