IUP Computer Science
CO 110  Spring '89

  Program #4  (Due 10 April)

    The Loretto Ordinary Object Sales Enterprise is a rather unorganized company, consisting mostly of sales staff who work when they feel like it.  The sales personnel are responsible for reporting to company headquarters whenever they make a sale.  In Loretto, one of the two sales managers (Gordon or Marie) takes the salesperson's report and makes a data entry on the computer.   A data entry has this form:

's'  'name'  EMP-NO  AMOUNT  DISTRICT  PRODUCT

where 's' is the manager code for the person making the entry ('G' for Gordon or 'M' for Marie); 'name' is the salesperson's last name (Gordon makes these entries) or the salesperson's first name (Marie makes these entries); EMP-NO is a 3-digit employee number; AMOUNT is the value of the sale in dollars and cents; DISTRICT is a number from 1 to 4 indicating the location of the sale; and PRODUCT is a number from 10 to 35 indicating the type of product.  There are 20 people on the sales staff; but all of them work part-time; in any given week, some of the salespersons will not make any sales.  Note:  The maximum length of a name (first or last) is 10 characters.

    At the end of the week, a company report must be produced based on the data entered by Marie and Gordon.  The report has three sections:  Employee Sales which shows the total sales for each employee who reported at all during the week, District Sales which shows the total sales for every district, and Product Sales which shows the total sales for each product that had any sales for the week.  The output form is shown below.

                    Employee Sales
Emp No    Name                  No. of Sales   Total Sales
 xxx     last       first           xx         $xxxx.xx
  .        .          .              .              .

    District Sales
District       Total Sales      +------------------------------+
  x            $xxxxx.xx        |where each 'x' represents one |
  .                  .          |digit position and 'last' and |
                                |'first' refer to an employee's|
    Product Sales               |last name and first name,     |
Type No.       Total Sales      |respectively.                 |
  xx           $xxxxx.xx        +------------------------------+
   .                 .

    The data for the company report will be made available to you in a file called 110P4-DATA.COMPSCI at about 9 am on April 6.   You should practice with your own data until then.

    Program Requirements:  Your program must

1. Use several sets of parallel arrays to hold the information for each part of the company report.
2. Use formatted output to display ALL lines in the company report.  The form shown should be adhered to.
3. Recognize the sentinel record which follows the data.  This record has something other than a 'G' or a 'M' in the manager code position.  On reaching the sentinel, print the report.
4. Use a user-defined function called FIND that has 3 arguments: an array, the number of elements in the array, and what value to look for.  This function examines the array and returns the position where the sought value is found.  If the value is not found, FIND must return 0.
5. You must hand in a flow diagram for this program, in addition to the program listing and the printed output.  The program listing and printed output must be generated in a batch operation and must be based on the data in 110P4-DATA.COMPSCI. The flow diagram must be on 8 1/2 x 11 paper.

Consider the following sample data.

'G' 'JONES' 421  167.43  1  13
'M' 'MARILYN' 288  627.90  1  22
'M' 'FRED'  339  438.65  4  13
'M' 'RAY' 421 738.11 4 13
'G' 'JONES' 421  274.49 2  22
'G' 'MCGRAW' 288  830.18  1 13        Based on this data, your
'G' 'DARKWA' 197 566.89  1  26        program should produce
'M' 'KWESI' 197  1021.03 2  19        the following report.  Any
'M' 'MARILYN' 288 412.29 4 13         character other than 'G'
'*' '     '  0  0.00  0  0            or 'M' may be the sentinel.


                    Employee Sales
Emp No    Name                  No. of Sales   Total Sales
 421     JONES      RAY              3         $1180.03
 288     MCGRAW     MARILYN          3         $1870.37
 339                FRED             1         $ 438.65
 197     DARKWA     KWESI            2         $1587.92

    District Sales
District       Total Sales         Notes:
  1            $ 2192.40          Some salespersons may not have
  2            $ 1295.52          their whole names in the
  3            $     .00          report.  Some districts may
  4            $ 1589.05          have NO sales for the week.
                                  Only products with non-zero
    Product Sales                 sales are shown in the report;
Type No.       Total Sales         and they are listed in
  13           $ 2586.66          numerical order.  Employees
  19           $ 1021.03          are listed in the order in
  22           $  902.39          which they first occur.
  26           $  566.89