Help with While Loop
Posted: Fri Aug 20, 2010 2:16 pm
When I run the following code, for some reason, it only loops on the statement "DISPLAY "Do a calculation? Y or N"." and I'm never given the chance to input for the statement "ACCEPT calculateBool.". Anybody know what's the problem? Thanks!
PERFORM UNTIL calculateBool = "N"
DISPLAY "Do a calculation? Y or N".
ACCEPT calculateBool.
DISPLAY "Enter the number of calcs requires : ".
ACCEPT numOfCalcs.
DISPLAY "Enter first number: ".
ACCEPT firstNum.
DISPLAY "Enter second number: ".
ACCEPT secondNum.
DISPLAY "Enter operator: ".
ACCEPT operator.
IF operator = "+" THEN
ADD firstNum, secondNum GIVING result
END-IF
IF operator = "*" THEN
MULTIPLY firstNum BY secondNum GIVING result
END-IF
DISPLAY "Result is = ", result.
STOP RUN.
PERFORM UNTIL calculateBool = "N"
DISPLAY "Do a calculation? Y or N".
ACCEPT calculateBool.
DISPLAY "Enter the number of calcs requires : ".
ACCEPT numOfCalcs.
DISPLAY "Enter first number: ".
ACCEPT firstNum.
DISPLAY "Enter second number: ".
ACCEPT secondNum.
DISPLAY "Enter operator: ".
ACCEPT operator.
IF operator = "+" THEN
ADD firstNum, secondNum GIVING result
END-IF
IF operator = "*" THEN
MULTIPLY firstNum BY secondNum GIVING result
END-IF
DISPLAY "Result is = ", result.
STOP RUN.