I an doing a program that uses the READ DATA statements. My problem is I can't print the headings. My program reads the data and displays it, but no heading before it. My other problem is adding up all the Pieces in the problem to display a total. I know that part is easy but it is not coming to me at all. :confused:

Heres what my output looks like:

Johnny Begood         265       145.75
Sally Great              650       422.50
Sam Klutz               177         88.50
Pete Precise            400       240.00
Fannie Fantastic      399       219.45
Morrie Mellow          200       110.00

 TOTALS                   0       110.00

It should look like this :

PIECEWORK WEEKLY REPORT

  Name                  Pieces       Pay
Johnny Begood         265       145.75
Sally Great              650       422.50
Sam Klutz               177         88.50
Pete Precise            400       240.00
Fannie Fantastic      399       219.45
Morrie Mellow          200       110.00

 TOTALS                   0       110.00

Here's the code I am using. I see no mistakes and looks just like the example programs in my book.

'

'                        ***Program to compute pay****



'                              Varibles Used

'                              Nam$          Name of worker
'                              Pieces        Pieces the workers have
'                              Pay           Pay for the worker
'                              Totalpay
'                              Totalpieces                                                  Count
'                              T1$, H1$, D1$, TL$

'******************************Program Mainline***************************


CLS
GOSUB InitializeImages
GOSUB Printheadings
GOSUB Processdetail
GOSUB Calculatetotals
GOSUB Printtotals
END


'****************************Initialize Images***************************

InitializeImages:
 LET T1$ = "                 PIECEWORK WEEKLY REPORT"
 LET H1$ = "   NAME                     PIECES          PAY"
 LET D1$ = " \                  \        ####       ####.##"
 LET TL$ = "   TOTALS                   #####       #####.##"
RETURN


'*******************************Print Headings*****************************

Printheadings:
 PRINT
 PRINT T1$
 PRINT
 PRINT H1$
 PRINT
 PRINT
RETURN

'*******************************Process Detail*****************************

Processdetail:
 CLS
 GOSUB Readdata
 DO UNTIL UCASE$(Nam$) = "END"
   GOSUB Calculateanswers
   GOSUB Printdetail
   GOSUB Readdata
 LOOP
RETURN


'*******************************Read Input Data****************************
Readdata:
 READ Nam$, Pieces
 DATA Johnny Begood, 265
 DATA Sally Great, 650
 DATA Sam Klutz, 177
 DATA Pete Precise, 400
 DATA Fannie Fantastic, 399
 DATA Morrie Mellow, 200
 DATA End, 0
RETURN


'******************************Calculate Answers***************************

Calculateanswers:

 IF Pieces <= 199 THEN
  LET Pay = Pieces * .5
 END IF
  IF Pieces >= 200 AND Pieces <= 399 THEN
  LET Pay = Pieces * .55
 END IF

 IF Pieces >= 400 AND Pieces <= 599 THEN
  LET Pay = Pieces * .6
 END IF
 IF Pieces >= 600 THEN
  LET Pay = Pieces * .65
 END IF
RETURN


'******************************Calculate Totals*****************************

Calculatetotals:
 LET Totalpieces = Totalpieces + Pieces
 LET TotalPay = TotalPay + Pay
RETURN




'*******************************Print Detail********************************

Printdetail:
 PRINT USING D1$; Nam$; Pieces; Pay
RETURN


'*******************************Print Totals********************************

Printtotals:
  PRINT
  PRINT USING TL$; Totalpieces; TotalPay
RETURN
'*******************************End of Program******************************

Looks good to me. I just can't figure out how to total up the Pieces and Pay and add the heading.


See anything? blah :mad: :)

Ok, I got the Totals to work but not the heading.

'
'                        ***Program to compute pay****



'                              Varibles Used

'                              Nam$          Name of worker
'                              Pieces        Pieces the workers have
'                              Pay           Pay for the worker
'                              Totalpay
'                              Totalpieces                                                  Count
'                              T1$, H1$, D1$, TL$

'******************************Program Mainline***************************


CLS
GOSUB Initializeimages
GOSUB Printheadings
GOSUB Processdetail
GOSUB Printtotals
END


'****************************Initialize Images***************************

Initializeimages:
 LET T1$ = "                 PIECEWORK WEEKLY REPORT"
 LET H1$ = "   NAME                     PIECES          PAY"
 LET D1$ = " \                  \        ####       ####.##"
 LET TL$ = "   TOTALS                   #####       #####.##"
RETURN


'*******************************Print Headings*****************************

Printheadings:
 PRINT
 PRINT H1$
 PRINT
 PRINT H2$
 PRINT
 PRINT
RETURN

'*******************************Process Detail*****************************

Processdetail:
 CLS
 GOSUB Readdata
 DO UNTIL UCASE$(Nam$) = "END"
   GOSUB Calculateanswers
   GOSUB Printdetail
   GOSUB Readdata
 LOOP
RETURN


'*******************************Read Input Data****************************
Readdata:
 READ Nam$, Pieces
 DATA Johnny Begood, 265
 DATA Sally Great, 650
 DATA Sam Klutz, 177
 DATA Pete Precise, 400
 DATA Fannie Fantastic, 399
 DATA Morrie Mellow, 200
 DATA End, 0
RETURN


'******************************Calculate Answers***************************

Calculateanswers:

 IF Pieces <= 199 THEN
  LET Pay = Pieces * .5
 END IF
  IF Pieces >= 200 AND Pieces <= 399 THEN
  LET Pay = Pieces * .55
 END IF

 IF Pieces >= 400 AND Pieces <= 599 THEN
  LET Pay = Pieces * .6
 END IF
 IF Pieces >= 600 THEN
  LET Pay = Pieces * .65
 END IF
 LET Totalpieces = Totalpieces + Pieces
 LET Totalpay = Totalpay + Pay
RETURN

'*******************************Print Detail********************************

Printdetail:
 PRINT USING D1$; Nam$; Pieces; Pay
RETURN


'*******************************Print Totals********************************

Printtotals:
  PRINT
  PRINT USING TL$; Totalpieces; Totalpay
RETURN
'*******************************End of Program******************************

Alrighty I solved it. I added a CLS to the Process Detail procedure so that wiped out the top heading. :)

This question has already been answered. Start a new discussion instead.