Challenge 3.8: Difference between revisions

From BR Wiki
Jump to navigation Jump to search
(Created page with "a)  The program will "fall through" and execute the error-handling routine in lines 80 and 90 even if a conversion error does not occur. So even if you type in numbers, not l...")
 
No edit summary
 
Line 8: Line 8:


c)  Line 40 prints the number 20; line 70 prints the number 20 also because we changed the value of MI and GAL, but we did not change the value of MPG.
c)  Line 40 prints the number 20; line 70 prints the number 20 also because we changed the value of MI and GAL, but we did not change the value of MPG.
<noinclude>
[[Category:Tutorial Answers]]
</noinclude>

Latest revision as of 16:02, 16 July 2013

a)  The program will "fall through" and execute the error-handling routine in lines 80 and 90 even if a conversion error does not occur. So even if you type in numbers, not letters, the line below "Miles Per Gallon = __" will say "please enter numbers, not letters", and RETRY will fail causing error 211. This is because the stop statement was removed and the program moves on to line 80 and 90 without being referred to. Error 211 occurs because the program cannot be retried if no error occurred while in RUN mode. It is important to separate error-handling routines with STOP statements. You will also learn about other ways to divert program execution in further chapters.

b)  Replace the exclamation mark before each line of the title with PRINT statements, and insert quotation marks on both ends of each line of the title. In short, turn the comment statements into PRINT statements.

c)  Line 40 prints the number 20; line 70 prints the number 20 also because we changed the value of MI and GAL, but we did not change the value of MPG.