Custom Search
 
  

 
CHAPTER 5

EXERCISE SOLUTIONS

The following programs present possible solutions to the exercises.

1. 10 FOR X = 20 TO 40 STEP 2

20 PRINT X

30 NEXT X

40 END

RUN

20

22

24

26

28

30

32

34

36

38

40

2. 10 LET Y = .01

20 FOR X = 1 TO 30

30 LET Y = Y*2

35 PRINT Y

40 NEXT X

50 END

RUN

2.00000000E-02

4.00000000E-02         NOTE: Small numbers are represented by E notation.

8.00000000E-02 

.16

.32

.64

1.28

2.56

5.12

10.24

20.48

40.96

81.92

163.84

327.68

655.36

1310.72

2621.44

5242.88

10485.76

20971.52

41943.04

83886.08

167772.16

335544.32

671088.64

1342177.28

2684354.56

5368709.12

10737418.24

3. 5 DIM A$(5)

10 DATA "CAROL"

20 DATA "CHUCK"

30 DATA "FRED"

40    DATA "JANE"

50    DATA "JOHN"

60    FOR X = 1 TO 5

70    READ A$(X)

80    NEXT X

90    FOR Y = 5 TO 1 STEP 1

100    PRINT A$(Y)

110    NEXT Y

120    END

RUN

JOHN

JANE

FRED

CHUCK

CAROL

4. 10 DIM G(9,4)

20 FOR P = 1 TO 9

30 FOR S = 1 TO 4

40 READ G(P,S)

50 NEXT S

60 NEXT P

70    PRINT "TOURNAMENT GOLF SCORES"

80    PRINT "ENTER PLAYER NUMBER (l-9)"

90    INPUT P

100    PRINT "ENTER GAME NUMBER (1-4)"

110    INPUT S

120    PRINT "PLAYER #";P;"SCORE FOR GAME #";S;"IS";G(P,S)

130    DATA 69,72,70,75,73,72,74,70,71,75,69,73

140    DATA 70,74,72,71,69,68,70,72,75,77,73,70

150    DATA 68,66,70,72,70,73,71,69,76,71,74,72

999    END

RUN

TOURNAMENT GOLF SCORES

ENTER PLAYER NUMBER (1-9)

?6

ENTER GAME NUMBER (1-4)

?2

PLAYER #6 SCORE FOR GAME #2 IS 77

5. 10 DEF FNP(C) = C (.20*C)

20 PRINT "ENTER ORIGINAL PRICE"

30 INPUT Z

35 IF Z = 0 THEN 60

40 PRINT "SALE PRICE IS $ ";FNP(Z)

50 GOTO 20

60 END

RUN

ENTER ORIGINAL PRICE

?15

SALE PRICE IS $ 12

6. 10 PRINT "ENTER MILES AND GALLONS"

20 INPUT M,G

30 GOSUB 60

40 PRINT "AVERAGE MILES PER GALLON IS";A

50 STOP

60 LET A = M/G

70 RETURN

99 END

RUN

ENTER MILES AND GALLONS

?250,10

AVERAGE MILES PER GALLON IS 25







Western Governors University
 


Privacy Statement - Copyright Information. - Contact Us

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