Help with EOF

Please use this Board for QBasic related requests ( file research, programming, etc.)

Moderators:Administrator, Global Moderator

Post Reply
Guest
Help with EOF

Post by Guest » Sat Dec 07, 2002 2:23 am

:o Hi Everyone, I am writing a simple payroll program that calculates the pay rate by the hours worked etc. I am having a problem with the EOF, it shows up on the output screen, also I need to calculate the total employees weekly pay, everything else is OK, I have tried so many different variables but I can't seem to get it, Here is my short program, If you can help me I appreciate your expertise!!!! Thanks

QB40 Program

Code: Select all

'
'This program is designed to calculate a payroll report
'weekly pay is calculated by multiplying the hourly rate
'by hours worked. The wrap up module has the total number
'of employees and the total pay of the employees.
'
'Variables: Employee.name$= Name of Employee
' hours.worked=hours worked
' hourly.rate= hourly rate
' weekly.pay= weekly pay
' total.weekly.pay=weekly pay plus weekly pay
'
'
'
'
'
'
'**************************************************************************
'*************************Intialization**********************************
CLS 'Clear screen
LET Total.employees = 0
LET total.weekly.pay = 0
PRINT TAB(30); "Payroll Report"
PRINT
PRINT "Employee", "Hourly", "Hours", "Weekly"
PRINT "Name", "Rate", "Worked", "Pay"
PRINT
d1$ = "\            \##.##      ##,###       #,###.##"
t1$ = "Total employees=======>;  ###"
T2$ = "Total Weekly Pay=====>; $$##,###.##"
T4$ = "End of Report"

'************************************Process File***********************
READ employee.name$, hourly.rate, hours.worked
DO UNTIL employee.name$ = "EOF"
        LET total.employee = total.employee + 1
        LET weekly.pay = hourly.rate * hours.worked
        LET total.weekly.pay = weekly.pay + weekly.pay + weekly.pay + weekly.pay + weekly.pay
        PRINT USING d1$; employee.name$; hourly.rate; hours.worked; weekly.pay
        READ employee.name$, hourly.rate, hours.worked
      
LOOP


'********************wrap up********************** *******************
PRINT
PRINT USING d1$; employee.name$; hourly.rate; hours.worked; weekly.pay
PRINT USING t1$; total.employee
PRINT USING T2$; total.weekly.pay
PRINT
PRINT "End of Report"

'**********************Data Follows*****************************
DATA Joe Lomax, 7.70, 40
DATA Ed Mann, 6.05, 38.5
DATA Louis Orr, 8.10, 45
DATA Ted Simms, 9.5, 39.5
DATA Joan Zang, 12.0, 92
DATA EOF,0,0
end

Guest

Re: Help with EOF

Post by Guest » Sat Dec 07, 2002 5:47 am

what is happening is that the program doesn't detect that it the file line says eof until after it prints it. you can fix this by takeing eof outta your file and instead of just saying LOOP at the end of your prog say LOOP UNTIL(EOF(1))

Guest

Re: Help with EOF

Post by Guest » Sat Dec 07, 2002 5:54 am

;D Got it Thanks, That worked!!!!, now I have 1 little bug left in my program, adding the total of all employees and having it output to Total Weekly Pay, right now it just adds the last employee twice. I appreciate your help!!!!

User avatar
crossroads
Administrator
Posts:34
Joined:Wed Feb 13, 2002 10:15 pm
Location:Germany
Contact:

Re: Help with EOF

Post by crossroads » Sat Dec 07, 2002 8:36 am

Try this (bold lines are changed):

CLS 'Clear screen
LET Total.employees = 0
LET total.weekly.pay = 0
PRINT TAB(30); "Payroll Report"
PRINT
PRINT "Employee", "Hourly", "Hours", "Weekly"
PRINT "Name", "Rate", "Worked", "Pay"
PRINT
d1$ = "\  \  ##.##  ##,###  #,###.##"
t1$ = "Total employees=======>  ###"
T2$ = "Total Weekly Pay=====> $$##,###.##"
T4$ = "End of Report"

'************************************Process File***********************
READ employee.name$, hourly.rate, hours.worked
DO UNTIL employee.name$ = "EOF"
  LET total.employee = total.employee + 1
  LET weekly.pay = hourly.rate * hours.worked
  LET total.weekly.pay = total.weekly.pay + weekly.pay
  PRINT USING d1$; employee.name$; hourly.rate; hours.worked; weekly.pay
  READ employee.name$, hourly.rate, hours.worked
LOOP


'********************wrap up********************** *******************
PRINT
PRINT USING t1$; total.employee
PRINT USING T2$; total.weekly.pay
PRINT
PRINT "End of Report"

'**********************Data Follows*****************************
DATA Joe Lomax, 7.70, 40
DATA Ed Mann, 6.05, 38.5
DATA Louis Orr, 8.10, 45
DATA Ted Simms, 9.5, 39.5
DATA Joan Zang, 12.0, 92
DATA EOF,0,0
END
crossroads (QBCafe Forum Admin)

Post Reply