Q1.
Design an algorithm that will produce a re-order list of products from a
product inventory file. Each input product record contains the item number,
the quantity on hand for the item, the quantity on order, the minimum
inventory level for that item, and an obsolete code (‘X’ if the item is obsolete,
blank if it is not).
Your program is to read the product file and determine which items are to be
reordered. An item is to be reordered if it is not obsolete and if the quantity
of the item currently on hand, plus the amount on order, is less than its
minimum inventory level. Print a detail line for each item to be reordered,
listing the item number, quantity on hand, quantity on order and minimum
inventory level. Print headings and column headings at the top of each page,
allowing for 45 detail lines per page, and at the end of the report, the total
number of items to be reordered.
Solution:
A. Characterizing Diagram.
Input Processing Output
inventory records print headings inventory details
item_num read inventory records item_num
Select reorder records
qty_on_hand Print reorder records qty_on_hand
Calculate total_rorder_items
qty_on_order Print total_reorder_items qty_on_order
min_inv_level min_inv_level
obsolete_code total_reorder_items
B. Hierarchy chart.
Process_
inventory_
records
Line_count inventory record
line_count
Print_ Print_
page_ recorder_
headings record
C. Solution algorithm
Process_inventory_records
1 Set page_count, line_count, total_reorder_items to zero
2 Print_page_headings (line_count)
3 Read inventory record
4 DOWHILE more records
5 IF line_count >= 45 THEN
Print_page_headings (line_count)
ENDIF
6 IF obsolete_code = blank THEN
IF (qty_on_hand + qty_on_order) < min_inv_level THEN
Print_reorder_record (inventory record, line_count)
add 1 to total_reorder_items
ENDIF
ENDIF
7 Read inventory record
ENDDO
8 Print ’Total reorder items’, total_reorder_items
END
Print_page_headings (line_count )
9 add 1 to page_count
10 Print main heading
11 Print column headings
12 Print blank line
13 Set line_count to zero
END
Print_reorder_record (inventory record, line_count)
14 Print item_num, qty_on_hand, qty_on_order, min_inv_level
15 add 1 to line_count
END
D. Desk Checking
i. Input data:
First Record Second Record Third Record
item_num 1111 2222 EOF
qty_on_hand 10 40
qty_on_order 10 40
min_inv_level 30 30
obsolete_code Blank Blank
ii. Expected results:
PRODUCT REORDER LIST
Item Quantity on Quantity on Minimum
number hand order inventory level
1111 10 10 30
Total reorder items 1
Statement qty_on_ qty_on Min_inv_ Total_reorder_ DOWHILE
number hand _ level records
order
1 0
2
9,10,11,12,1
3
3 10 10 30
4 true
5
6
14 Print Print print
15 1
7 40 40 30
4 true
5
6
7 EOF
4 false
8 print
Q2.