Custom Search
 
  

 
CHAPTER 6

EXERCISES

1. Layout and print three columns of data with headings. The headings are: NAME, RANK, and SERVICE NUMBER. The data is: name (allow 26 positions), rank (allow 5 positions), and service number (allow 11 positions). Assume a report width of 60 positions. Write PRINT statements using TAB to center the headings over each column of data and print the data. As nearly as possible, allow an equal number of spaces between columns.

2. Assume the numeric-variable D can have a range of values from .0001 to 99999.99. Write a PRINT USING statement and associated format line to format and print the numeric-variable D. Include dollar sign, comma, and decimal point. Use the rounding method shown in the chapter to round off to two decimal places.

3. Remember the program from Chapter 5, which doubled the value of a penny every day for 30 days. It is listed below. Look at the output; the numbers are rather lengthy and awkward to read. Modify the program to print the values with:

A. the decimal points lined up

B. a $ at the beginning of each value

C. commas in appropriate positions

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

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

4. Write a program to compute and print the discounted prices of a list of items for any discount rate. The discount rate should be input at the time the program is executed. Put a title and column headings on the printed report. Allow 10 positions for item name and up to $9,999.99 for unit price.

Use the following list of items as the data:

Items           Unit Price

TIRES         $ 379.95

BATTERY  61.95

ENGINE      1032.50

FUSES         .55







Western Governors University
 


Privacy Statement - Copyright Information. - Contact Us

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