Can you please double check this code...
Posted: Thu Sep 06, 2012 2:13 pm
Hey guys, its me again, im taking a BASIC class in college and am having trouble with it for some reason... the assignment is was given was to write a program that will request length and width of a rectangle until 0 is entered for either the length or width.
here is the code i am supposed to follow:
Initialize screen
GOSUB InputData
DO until Width = 0 OR Length = 0
GOSUB CalculateRectangle
GOSUB PrintResults
GOSUB InputData
LOOP
END
CalculateRectangle contains processing formulas
PrintResults contains printout with appropriate labels
GOSUB InputData again or it?ll be an endless loop
here is my code:
REM ******************************************************************
REM *** This program will find the length and width of a rectangle ***
REM ******************************************************************
REM
REM ***PROGRAM MAIN BODY***
CLS
GOSUB InitializeScreen
GOSUB CalculateRectangle
GOSUB PrintResults
GOSUB InputData
RETURN
END
REM ********************************
REM *** Initialize Screen ***
REM ********************************
InitializeScreen
CLS
RETURN
REM *********************************
REM *** Print Results ***
REM **********************************
InputData:
INPUT "Calculate length:$"; Calclength
INPUT "Calculate width:S"; Calcwidth
CLS
RETURN
DO UNTIL Calcwidth = 0 OR Calclength = 0
LOOP
PrintResults:
PRINT "Calculate length:$"; Calclength
PRINT "Calculate width:$"; Calcwidth
END
As you can see its different then the given but when it comes to the DO UNTIL statement I just cant input "WIDTH" I get an error, can some please help me.. I emailed my teacher but have gotten no response in a week!
here is the code i am supposed to follow:
Initialize screen
GOSUB InputData
DO until Width = 0 OR Length = 0
GOSUB CalculateRectangle
GOSUB PrintResults
GOSUB InputData
LOOP
END
CalculateRectangle contains processing formulas
PrintResults contains printout with appropriate labels
GOSUB InputData again or it?ll be an endless loop
here is my code:
REM ******************************************************************
REM *** This program will find the length and width of a rectangle ***
REM ******************************************************************
REM
REM ***PROGRAM MAIN BODY***
CLS
GOSUB InitializeScreen
GOSUB CalculateRectangle
GOSUB PrintResults
GOSUB InputData
RETURN
END
REM ********************************
REM *** Initialize Screen ***
REM ********************************
InitializeScreen
CLS
RETURN
REM *********************************
REM *** Print Results ***
REM **********************************
InputData:
INPUT "Calculate length:$"; Calclength
INPUT "Calculate width:S"; Calcwidth
CLS
RETURN
DO UNTIL Calcwidth = 0 OR Calclength = 0
LOOP
PrintResults:
PRINT "Calculate length:$"; Calclength
PRINT "Calculate width:$"; Calcwidth
END
As you can see its different then the given but when it comes to the DO UNTIL statement I just cant input "WIDTH" I get an error, can some please help me.. I emailed my teacher but have gotten no response in a week!