## All-together now: tying up the whole semester

When you have a new problem to solve, you should ask yourself: do I need to store stuff beyond local variables? should I use an array? should I use a 2D array? should I use a struct? should I use a linked list? Do I need to sort? The answers to these questions will help shape your solution. Below are two Problem Scenarios, each with several variations of what problem actually needs to be solved. Annotate each with your answers to the above questions, along with justifications!

Problem I: Customer orders come in to a warehouse like this: (customerID, itemNumber, quantity) and these items are prefetched and brought to a holding area. Then the command to ship to customer identified by ID comes in, and all the prefetched items are shipped to that customer in a single box. Assume the total number of items in the order (sum or quantities) is all that's required to determine the box size. Assume each customerID is a unique string of upper-case letters , e.g. "JONEXXK" or "BROWKZL".

A. Read from user a sequence of commands:

 add (JONEXXK,228700,5) <-- adds this item to the orders

maxq <-- prints out the (customerID, itemNumber, quantity) of order
with the largest quantity seen so far.  If no items have

quit <-- quits program

B. Assume that the system will not need to process more than 1000 orders before quitting. Read a sequence of commands:

add (JONEXXK,228700,5) <-- adds this item to the orders

print <-- writes out all the orders (don't care what order they appear)

quit

C. Assume that the system will not need to process more than 1000 orders before quitting. Read a sequence of commands:

add (JONEXXK,228700,5) <-- adds this item to the orders

print <-- writes out all the order summaries for each customer, like
this:

BROWKZL
108520 4
228700 1
920022 1
Total: 6
JONEXXK
800231 2
920022 1
998735 10
Total: 13

Customers should be listed alphabetically by CustomerID.

quit <-- quits program

D. Make no assumption about number of orders. Now we add a command to ship to a customer, which should print a summary of the order, and remove the shipped orders from storage. If a customerID is entered with the ship command for which there are no unshipped orders, print "No orders pending!".

add
ship CustomerID
quit

Problem II: Your job is to read in a bunch of (alphacode,1/C..4/C,M/F,100m-sprint-times) data lines like:

(183488,4/C,F,11.33)

and process them.

A. print the average time

B. print average times for each class/gender (8 total)

C. print the alphacodes/class/gender/time of the first 20 data lines (read in but ignore all subsequent lines) in increasing order of times. If multiple data lines have the same time, they should appear in increasing alphacode order.

D. after reading the data lines, you are given a range (rmin,rmax). Print the alphacodes/class/geneder/time of all mids whose 100m-sprint-time lies within the range.