[Santa Clara University]
Department of Mathematics
and Computer Science

Machine Problem 2

Math 169
D. C. Smolarski, S.J.
Fall 2007

                              
Language: COBOL
30 points
DUE: Part I, Noon, Tuesday, Oct 23, 2007
Part II, Noon, Thursday, Oct 25, 2007

Gentle Reminder: This program is to be done individually, without any collaboration! See the information found on the web page: General Rules and Other Information.

This program is to be done using COBOL. See on-line information about how to use COBOL on math.

Part I - Factorial Problem.

Read in an arbitrary number of numbers. The numbers are in signed 5 digit decimal format in file cobfac.inp (all lower case).

You can copy this file (as with the Fortran input file) from my directory via

   cp /home/dsmolars/ma169/cobfac.inp .
(again, don't forget the final period after a space!). For the integers between 0 and 10 calculate their square and factorial and print the results in reverse order. In other words, if the first element of the list is 3, then 3x3 = 9 and 3! = 6 should be the last values outputted. If the integers are negative or greater than 10 print an appropriate error message. The input file again should be 3, -2, 10, 25, 8. NOTE again the special way that negative numbers appear in COBOL (derived from the format used on IBM cards).

Part II - COBOL SPECIFIC PROBLEM.

MACY'S INVENTORY

Macy's has four stores in the Greater New York Area. The inventory for these stores is kept at the downtown office. The inventory is updated weekly and a report generated. This week's inventory for ONE STORE is in the file cobmac.inp. You can copy this file from my class directory on math as described above. You are to have the program read this file and generate the report.

The file is a sequence of records which contain the following fields in the order given:

CARD-TYPE This is a single character that Determines which type of card this is.

S is a store card.
D is a department card.
I is an item card.
The STORE CARD has the following additional fields:
STORE-NUMBER Single digit which is an index into the store array described below.

STORE-MANAGER which has the following subfields:

NAME Manager's name, 30 alphanumeric characters.
PHONE Manager's office phone, 7 digits, unsigned.
HOMEPHONE Manager's home phone, 7 digits, unsigned.
The DEPARTMENT CARD has the following additional fields:
DEPT-MANAGER Manager's name, 30 alphanumeric characters.
DEPT-TITLE 49 alphanumeric characters.
The ITEM CARD has the following additional fields:
ITEM-NO Inventory number, unsigned 5 digit field.
ITEM-NAME Display name, 30 characters.
ITEMS-IN-STOCK The number of items on the shelves and in the supply room. this number can be negative, implying that customers have placed orders for this item. The number is 5 digits long.
ITEM-UNIT-VALUE Price per item, unsigned 7 digit field containing the amount in cents.
PAYMENTS If the ITEMS-IN-STOCK is negative, this field may contain a negative amount. The field is a signed 7 digit field containing the amount in cents.
The fields have been listed in order from left to right. The fields STORE-NUMBER, DEPT-MANAGER, and ITEM-NO all begin in column two. There will be no intervening spaces between fields. The order of records in the field will be hierarchical. The first card will be a store card, followed by a department card. Following the department card will come the items in that department. The items for a given department will end with a new department or store card. Items will be sorted within departments by inventory number.

The report which you are to write is a two level report. The first level is per department, and the second level is per item. At the end of each department , subtotals should be printed for both payments and totals. At the last lines (after the subtotal for the store), the grand totals (summing the individual total of the store) should be printed.

The report must also be divided into pages with page numbers at the top of each page (note that a store might have a long report that continues for several pages, each of which should have a new number). (The approximate number of lines per page is 60.)

The store reports are to begin on a new page. The title line must include the store manager's name and phone numbers. The phone numbers must be labeled.

The department report also has a title line including all the information given about the department. This should be followed by the column headings for the items in the department. Use blank lines around the department reports (title line to totals line) for readability.

Each item line contains the fields ITEM-NO, ITEM-NAME, ITEMS-IN-STOCK, ITEM-UNIT-VALUE, PAYMENTS, and the total value of the inventory (number of items times unit value) separated by spaces for readability. The amounts listed in the payments category should be followed by a 'CR' if less than zero. Dollar amounts should have a dollar sign immediately to the left of the leftmost digit (with no leading zeroes). Totals should be compiled for the payments and total value columns.

The store array (indexed by the store number) is to be built into your program as static data. It contains the following information about each store.

		1.	Paramus Shopping Center.
		2.	Westchester Macy's.
		3.	Bronx outlet.
		4.	Macy's, Downtown Office.
You do not know the store whose data is in the file and you should not "peek" into the file to determine which store it is. That is to be done by the program with the internal data.

This program is really just a formatting exercise. Please take note that the form of your output on this MP will be the majority of your points. The other important points are how you nest the code for each type of report, and how you handle the pagination. Don't believe the spacing in the sample below. Good luck.

SAMPLE DEPARTMENT					DENNIS SMOLARSKI

 ITEM		ITEM		    ITEMS   ITEM UNIT  PAYMENTS  TOTAL
NUMBER		NAME		  IN STOCK      VALUE
 0020	MP4 HANDOUT			80      $1.00	$0.00   $80.00
 0030	FINAL EXAM ANSWERS		 0    $500.00   $0.00    $0.00
                                --------------------------------------
							$0.00   $80.00

This page is maintained by Dennis C. Smolarski, S.J. dsmolarski at math.scu.edu
© Copyright 2007 Dennis C. Smolarski, SJ, All rights reserved.
Last changed: 11 October 2007.