< previous page page_226 next page >

Page 226
means 14 pieces of 2-inch by 4-inch lumber, each 8 feet long. To compute the quantity ordered, you have to calculate the total volume ordered. The unit for lumber volume is the board foot, which is equivalent to 1 square foot of lumber, 1 inch thick, or 144 cubic inches. The quantity ordered in the sample input is 74.67 board feet. To determine the board feet, we use this formula:
(2 in. × 4 in. × (8 ft × 12 in./ft) × 14 pieces)/144 cubic in. per board foot
For plywood, the first two numbers are the thickness of the sheet, expressed as a fraction; the third number is the length of the sheet in feet; and the last number is the number of sheets ordered. The lumberyard only stocks plywood sheets in 4-foot widths, so there's no need to enter the width. The entry
P 3 4 8 6
means 6 sheets of ¾-inch-thick plywood, 8 feet long (and 4 feet wide). Again, to compute the quantity ordered, you have to calculate the total volume ordered. At this lumberyard, the unit for plywood volume is a full sheet. A full sheet is 4 feet (48 inches) wide, 8 feet (96 inches) long, and 1 inch thick, or 4608 cubic inches. For the sample input, the quantity ordered is 4.5 full sheets. We use this formula:
(6 sheets×¾in. × (8 ft × 12 in./ft) × 48 in.)/4608 cubic in. per sheet
Input: A letter (code) and four integer numbers (sizel, size2, size3, numOrdered).
Output:
A prompt for input
The input values (echo print)
Result of calculating the quantity ordered
Discussion: To do this problem by hand, you would read the letter and four numbers and examine the letter to decide what to do. If the letter is L, you first would change all the units to inches and then multiply the four numbers together to get the total volume. Then you would divide the result by 1 board foot (144 cubic inches). If the letter is a P, you would change all the units to inches again, divide the first number by the second to get the thickness, then multiply the dimensions (don't forget the width) by the

 
< previous page page_226 next page >