V22.0002 - ASSIGNMENT 3


A stock brokerage company wants to know to which stock exchange its brokers are sending their customers' orders. Write a program that allows the company to track its orders.

For every order, the broker will enter the number of shares and the exchange (note that the user is not entering every detail of an order - just those two pieces of information).

After all the data is entered, the program should print to the screen for each exchange the number of orders, the number of shares, as well the average number of shares per order.

There are two possible exchanges for this exercise, as follows: the New York Stock Exchange ("NYSE"), and the American Stock Exchange ("ASE"). For data input, use 1 to represent the NYSE, and 2 to represent the ASE. You should reject order data for any other values for exchange.

You should use a sentinel of 0 or less for shares to signal the end of data input. That is if the user enters a 0 or a negative number that will signal the end of input.


Ex:

Welcome to the Destination Summary program.
You will enter the number of shares and the destination
exchange for each order.  Possible exchanges are represented
by the numbers 1 and 2, for the New York, and
American Stock Exchanges, respectively.

To end the program, enter 0 or less for the number of shares.

Please enter the number of shares for the next order (enter 0 or less to end):
101
Please enter the destination exchange for this
order (1 (NYSE) or 2 (ASE)):
1

Please enter the number of shares for the next order (enter 0 or less to end):
200
Please enter the destination exchange for this
order (1 (NYSE) or 2 (ASE)):
2

Please enter the number of shares for the next order (enter 0 or less to end):
100
Please enter the destination exchange for this
order (1 (NYSE) or 2 (ASE)):
1

Please enter the number of shares for the next order (enter 0 or less to end):
300
Please enter the destination exchange for this
order (1 (NYSE) or 2 (ASE)):
7
ERROR: 7 is not a valid exchange.  Rejecting data.

Please enter the number of shares for the next order (enter 0 or less to end):
100
Please enter the destination exchange for this
order (1 (NYSE) or 2 (ASE)):
2

Please enter the number of shares for the next order (enter 0 or less to end):
0

Summary Statistics:
-------------------
New York Stock Exchange:
 2 order(s), 201 share(s), average 100.50 share(s) per order
American Stock Exchange:
 2 order(s), 300 share(s), average 150.00 share(s) per order

Notes and Hints: Updated October 9, 2003