help with program

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

Moderators:Administrator, Global Moderator

Post Reply
qbasicclass
help with program

Post by qbasicclass » Tue Sep 28, 2004 10:46 pm

Can someone please help me. I have written two programs. The first programs will run up to the rows of info then it will put in end for the name and the end total and not each number then a total. I've been working on this for a week. Please help

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

CLS
GOSUB InitializeImages
GOSUB ProcessDetail
END

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

InitializeImages:
LET T1$ = " Recording Studio Rent Charges"
LET H1$ = " Group Name Mintues Used Charges"
LET D1$ = " \ \ #### $#,###.##"
LET TL$ = " "
RETURN

'*********Process Detil*******************

ProcessDetail:
CLS
PRINT TAB(25); "Recording Studio Rent Charges"
GOSUB InputData
DO UNTIL UCASE$(Name$) = "END"
GOSUB inputMinutes
GOSUB CalculateCharge
PRINT
GOSUB InputData
LOOP
GOSUB PrintTitleAndHeader
GOSUB Summarize
GOSUB PrintOutput

RETURN

'*********Input Data**********************

CLS
InputData:
PRINT

INPUT "Name of group (END to Quit)"; Name$
RETURN

'********Input Minutes***************

inputMinutes:

INPUT "Enter Minutes used"; Minutes
RETURN

'*********CalculateCharge*************

CalculateCharge:
LET hourrate = 200
LET Rate = (hourrate / 60) * Minutes
LET Charge = INT(Rate * 100 + .5) / 100
PRINT
LET TotalMinutes = TotalMinutes + Minutes
LET TotalCharge = TotalCharge + Charge

RETURN

'***********Summarize****************

Summarize:
PRINT USING D1$; Name$; Minutes; TotalCharge
RETURN

'*********PrintTitleAndHeader**********
PrintTitleAndHeader:
PRINT
PRINT TAB(20); T1$
PRINT
PRINT H1$

RETURN

'*********Print Output********************

PrintOutput:
PRINT



PRINT "Total Charge for All Groups"; TotalCharge;



RETURN

'****************EndofProgram**************

Guest

Post by Guest » Fri Oct 01, 2004 5:37 am

Code: Select all

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

 CLS
 GOSUB InitializeImages
 GOSUB ProcessDetail
 END

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

InitializeImages:
 T1$ = " Recording Studio Rent Charges"
 H1$ = " Group Name Mintues Used Charges"
 D1$ = " \         \ ####     $#,###.##"
 TL$ = " "
RETURN

'*********Process Detil*******************

ProcessDetail:
 CLS
 PRINT TAB(25); "Recording Studio Rent Charges"
 GOSUB InputData
 DO UNTIL UCASE$(Name$(k&)) = "END"
  GOSUB inputMinutes
  GOSUB CalculateCharge
  PRINT
  GOSUB InputData
 LOOP
 k& = k& - 1
 GOSUB PrintTitleAndHeader
 GOSUB summarize
 GOSUB PrintOutput

RETURN

'*********Input Data**********************

 CLS
InputData:
 PRINT
 k& = k& + 1
 INPUT "Name of group (END to Quit)"; Name$(k&)
RETURN

'********Input Minutes***************

inputMinutes:

 INPUT "Enter Minutes used"; Minutes(k&)
 RETURN

'*********CalculateCharge*************

CalculateCharge:
 hourrate = 200
 Rate(k&) = (hourrate / 60) * Minutes(k&)
 Charge(k&) = INT(Rate(k&) * 100 + .5) / 100
 PRINT
 TotalMinutes = TotalMinutes + Minutes
 TotalCharge = TotalCharge + Charge(k&)

RETURN

'***********Summarize****************

summarize:
 FOR x& = 1 TO k&
  PRINT USING D1$; Name$(x&); Minutes(x&); Charge(x&)
'TotalCharge
 NEXT
RETURN

'*********PrintTitleAndHeader**********
PrintTitleAndHeader:
 PRINT
 PRINT TAB(20); T1$
 PRINT
 PRINT H1$

RETURN

'*********Print Output********************

PrintOutput:
 PRINT
 PRINT "Total Charge for All Groups"; TotalCharge;
RETURN

'****************EndofProgram**************
[/code]

Buff1

Post by Buff1 » Fri Oct 01, 2004 5:41 am

One comment about the code i posted. If you use 10 or more
items you will have to dimension the arrays before using so it
would be a good idea to dim them anyway
DIM charges(100),name$(100),minutes(100),rate(100)

for example at the beginning of the program.

Buff1

Post by Buff1 » Fri Oct 01, 2004 5:44 am

one other comment. the CLS just before InputData: will NEVER be accessed. Therefore it is unnecessary there.

RalphA

Use of CLS at beginning of program

Post by RalphA » Mon Nov 08, 2004 5:28 pm

Buff1 wrote:one other comment. the CLS just before InputData: will NEVER be accessed. Therefore it is unnecessary there.
Actually, it IS accessed, as soon as the program starts, as the first command.

Personally, I use the CLS command at the beginning of my programs, just to be sure the screen is clean when the program runs. This is especially helpful when you are troubleshooting, and want to know what each run of the program actually accomplishes. Or, if you must run the program more than once.

Post Reply