There is a store that holds a certain quantity of 3 kinds of items, A, B, and C that are will be put up for sale on one day. A million potential customers have been invited to come and buy these items. Each customer may buy at most one of each of A, B, and C. Each customer is also given a claim number.
On the day of the sale, customers arrive all at once and are serviced in order of their claim number. Not all potential customers will necessarily come. And even if all come, the store may run out of one or more items before some people are serviced. If a customer arrives for service and one of the desired items is unavailable, they may still buy the others if they are available.
The program reads as input data:
1. The numbers of A's, B's, and C's available, along with their quantities
Input format for each is
a letter (A, B or C), followed by a space, then
a nonnegative integer quantity.
2. A list of customers
Input format is
a maximum of 20 characters denoting customer last name
(each name is unique) followed by a space, then
a non-negative claim number, then a space, then
one to three letters (A, B or C) indicating which item(s)
the customer will buy.
The end of the list contains only a `*'
The program outputs:
1. A list of purchases of the form
Item Name
with one line per purchase. (So, a customer
buying one of each item would get listed on three lines. Order
of printing is not important
2. A summary of the total numbers of each item sold.
3. A second listing of all unfullfilled requests and their
totals, as shown below.
Example 1.
Input
A 1
B 0
C 1
Smith 1 ABC
*
Output
SALES
Item Name
A Smith
C Smith
Totals:
A 1
B 0
C 1
REQUESTED BUT NOT SOLD
Item Name
B Smith
Totals:
A 0
B 1
C 0
Example2
Input
A 11
B 3
C 1
Clinton 1600 AC
Bush 7 BC
Reagan 20 A
Carter 1976 C
Ford 22 B
Nixon 666 AB
Johnson 43 ABC
Kennedy 2 AB
Eisenhower 1952 BC
*
Output
SALES
Name Item
A Kennedy
A Johnson
A Nixon
A Clinton
A Reagan
B Kennedy
B Bush
B Ford
C Bush
Totals:
A 5
B 3
C 1
REQUESTED BUT NOT SOLD
Name Item
Johnson B
Johnson C
Nixon B
Clinton C
Eisenhower B
Eisenhower C
Carter C
Totals:
A 0
B 3
C 4