Custom Search
 
  

 
CHAPTER 4

EXERCISE ANSWERS

1.      A. Control will be transferred to line 90

B. An integer value of 3 will transfer control to line 130

C. An integer value of 1 or 4 will transfer control to line number 50. Statement numbers may be repeated in line number specifications in ON-GOTO statements.

2. ON A/10 GOTO 60, 80, 80, 150, 150, 180 

In this example the value of the variable is divided by a- specified number to get the integer value.

3. A. An entry other than a 1 or 2 would cause lines 70 and 80 to be executed.

B. The line numbers of the statements that would be executed following line number 50 are 60, 90, 100, 130, 140, 170, and the program will stop at 180 and wait for a response.

C. The purpose of statements 170-190 is to control the loop. Statement 190 tests the value of the string variable, Q$; if it is equal to Y (more input), then control is transferred back to statement number 10 to request and process the next input. If Q$ is equal to N (no more input) execution of the program is terminated by statement number 200.

4. This is one way the program could be written to solve the problem.

10        DATA    50.00, 37.40, + 320.45, 100.20, + 25.00

11        DATA    85.35, 250.00, +200.00,0

20        PRINT    "ENTER BEGINNING BALANCE"

30        INPUT    B

40        PRINT    "YOUR BEGINNING BALANCE IS $";B

50        PRINT    "CHECKS/DEPOSITS ","BALANCE"

60        READ C

70        IF C = 0 THEN 110

80        LET B = B + C

90        PRINT C, B

100        GOTO 60

110        IF B>500 THEN 150

120        PRINT "A SERVICE CHARGE OF $4.00 HAS BEEN ";

130        PRINT "DEDUCTED FROM YOUR ACCOUNT."

140        LET B = B 4.00

150        PRINT     "YOUR FINAL BALANCE IS $";B

999        END

RUN

ENTER BEGINNING BALANCE

?

YOUR BEGINNING BALANCE IS $2450.25

CHECKS/            BALANCE
DEPOSITS 

50             2400.25

37.4          2362.85

320.45        2683.3

100.2         2583.1

25                 2608.1

85.35          2522.75

250             2272.75

200               2472.75

YOUR FINAL BALANCE IS $2472.75







Western Governors University
 


Privacy Statement - Copyright Information. - Contact Us

Integrated Publishing, Inc. - A (SDVOSB) Service Disabled Veteran Owned Small Business