Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Write a program to produce a bonus report. See the problem definition in Figure 9.7.
Notes:
The payroll records have been sorted into ascending sequence by office number within territory number. There are three territories, two offices within each territory, and 10 employees within each office. We have, therefore, 60 records (3 × 2 × 10). Thus, all employees within office 01 within territory 01 will appear before employee records for office 02 within territory 01, and so on.
Only employees who were hired before 1994 are entitled to a 10% bonus.
Interactive Processing. Write a program to display a temperature conversion table on a screen. Compute and print the Fahrenheit equivalents of all Celsius temperatures at 10-degree intervals from 0 to 150 degrees. The conversion formula is Celsius 5/9 (Fahrenheit 32). Note: This program does not need an input data set.
The problem definition for this program appears in Figure 9.8.
Given the initial cost of an item, print a table indicating the item's anticipated cost over a 10-year span taking inflation into account. Assume the inflation rate for the first 5 years is projected at 8% and the inflation rate for the next 5 years is projected at 6%. Be sure to accumulate the effects of inflation. Look at the following example before you write the program.
ITEM-COST: $1.00
YEAR 1 1.08 (1 X 1.08)
YEAR 2 1.082 (1.08 X 1.08)
.
.
.
YEAR 5 1.085
YEAR 6 1.085X 1.06
.
.
.
YEAR 10 1.085X 1.065Interactive Processing. Redo Programming Assignment 3 and enter the item number, description, and cost interactively. Also enter the inflation rates for the first five years and the next five years from the keyboard. Display the results on the screen.
Write a program to compute class averages for an input disk file with the following format.
| Record 1 for group: |
1–5 Class number
6–7 Number of students in class 8–10 Not used |
| Remainder of records for group: |
1–5 Class number
6–8 Exam grade (999) 9–10 Not used |
Print: Class number and class average for each class. The average should be rounded to the nearest integer.
Write a program to print one line from a variable number of input records, where the first record of each group indicates the total number of records in the group. Each group of records pertains to a single salesperson and consists of all sales that person transacted during the month. The output is a printed report with each line consisting of a salesperson name and the accumulated amount for the total number of records in the group. The problem definition appears in Figure 9.9. Use a READ ... INTO to define the two input record layouts in WORKING-STORAGE.
The We-Sell-Low Store has twenty-five salespeople. For each day of the week (Mon–Sat), a record is created that includes:
| SALES Record Layout | |||
|---|---|---|---|
| Field | Size | Type | No. of Decimal Positions (if Numeric) |
| DAY-OF-WEEK
(1 = Mon 2 = Tue . . . 6 = Sat) | 1 | Alphanumeric | |
| SALESPERSON-NUMBER | 2 | Alphanumeric | |
| TOTAL-AMOUNT-SOLD | 7 | Numeric | 2 |
The records are in sequence by Day of Week (1–6) and within day of week, by salesperson number (1–25).
Print a report indicating the total amount sold for each day:
Print a depreciation table using the straight-line method of depreciation.
The Internal Revenue Service permits a tax write-off depending on the expected life of an asset. The amount to be depreciated or written off may be deducted from taxable income. For this reason, depreciation schedules are prepared by companies for many of their assets. In this way, each year's write-off or depreciation is simply obtained from the table entry for that year. The asset's value at any given time is referred to as its book value. This is equal to its initial value minus the accumulated depreciation.
At the end of the anticipated useful life of an asset, its value should depreciate to the salvage or scrap value. We call this REM-VAL for remaining value. Suppose, for example, that the useful life of an item such as an automobile is considered to be 5 years. If the car is estimated to have a value of $2,000 at the end of 5 years, that amount is referred to as the salvage or remaining value.
There are numerous ways of spreading depreciation over the life of an asset. Your program should use the method referred to as straight-line depreciation, which means that an amount equal to the original cost (purchase price) of an asset minus its salvage value may be written off each year of the asset's depreciable or useful life.
To prepare a depreciation table for a given asset using the straight-line method, use the problem definition shown in Figure 9.10. Beginning with the current period, calculate depreciation as follows:
Depreciation = (Purchase Price Remaining Value) / Useful Life
Print a depreciation table indicating yearly depreciation values. If, for example, an asset were expected to last for 6 years, one-sixth of the asset would be depreciated each year. This is because with straight-line depreciation the amount of depreciation is the same for each period. There would thus be 6 yearly depreciation figures printed out in the depreciation table.
Tables are produced indicating the amount of depreciation or write-off each year from the current date to the end of the useful life of the asset.
Suppose a piece of equipment has a purchase price of $11,000 and a salvage value of $1,000. We wish to produce a 3-year table of depreciation. Thus, there will be three yearly figures to be calculated.
The depreciation is calculated as follows:
The depreciation per year for each of 3 years is 3333.33. Using straight-line depreciation, the rate is the same each year.
For each Item Description, Cost, and Number of Years entered, print a depreciation table.
Interactive Processing. Write a program to enable users to enter:
Name
Street Address
City, State, and Zip
on three lines of a screen. Prompt the user for the number of mailing labels needed:
DISPLAY 'ENTER NO. OF MAILING LABELS' ACCEPT NO-OF-LABELS
Display all accepted input on the screen again, asking the user to verify that it is correct (e.g., 'IS THE DATA CORRECT (Y/N)?'). If the user responds by keying Y for 'yes' (upper- or lowercase Y should be acceptable), then print the required mailing labels on the printer. If you are using a PC, make the interactive screen display as interesting as possible (e.g., use different colors, highlighting, etc.).
Interactive Processing. Students, particularly those in elementary school, sometimes have to write a line such as "I will not chew gum in class." on the board a number of times. Modernize this process. Write a program that will interactively ask the user for the message and the number of times it must be written, and then write the message to a file the required number of times. The lines should be numbered.
Interactive Processing. Modify the above program to output to a screen instead of a file. Display 20 lines on a screen and stop until the user wants another screen's worth.
Maintenance Program. Modify the Practice Program in this chapter so that the interest earned each year appears on each detail line printed.
Hint: For the first year, subtract the initial principal amount from the new balance at the end of the first year. Thereafter, subtract the previous year's balance from the new balance at the end of the corresponding year. Also add today's date to the heading.
Maintenance Program. Modify the interactive version of the Practice Program so that:
The YES/NO part of the AGAIN prompt is a different color than the rest of the prompt.
Either upper- or lowercase yes or no responses will control the loop.
Upper- or lowercase Y and N also will control the loop.
Change the colors to something else.
Maintenance Program. Modify the interactive version of the Practice Program to include a screen that asks if the input is correct before continuing processing.
Maintenance Program. Modify the factorial example on p. 357 so that it works for 0! (0! = 1).
Interactive Processing. Many states issue license plates with the format ABC-123. Write a program that has starting and ending plate numbers entered from the keyboard and prints out a list of the plate numbers between and including the ones entered. Be sure to "carry" so the program works for situations such as when the sequence goes from AAA-999 to AAB-000. (Note that the digits change faster than the letters.)
CASE STUDY