COSC 071: Computer Science I

Project 2
Spring 2001

Due: Mar 14th @ 4 PM
5 points

BelliesAreUs has hired you to write a new inventory system for their Next Generation Software Initiative. This will be a transaction processing system that will update the inventory when the company buys and sells pork bellies. Naturally, 'bellies' are traded on the commodities exchange, so their price fluctuates with demand. And at any time, management may want to issue a request for a valuation of the current inventory.

To simulate the actual transactions, we will use a data file to store one day's transactions. The first two records of the file will contain the total number of bellies on-hand and their opening price, which is equal to the closing price on the previous day. An unspecified number of transactions will follow. Each transaction or record will have the time when the transaction occurred, a three-letter transaction code, and a floating-point number.

The transactions and their respective codes are as follows:

BEG Beginning amount in pounds of pork bellies on-hand
PRC Opening price of pork bellies per pound
UPD Price update of pork bellies per pound
PUR Purchase of pork bellies in pounds
SAL Sale of pork bellies by the pound
REQ Request for a valuation of current inventory

If at any time, the program shows that the amount of bellies on-hand is zero, then the program should stop processing sales until the inventory is replenished. Your program should also keep track of the total amount (pounds and dollars) of pork bellies sold.

The Pork Bellies Exchange Commission (PBEC) is always on the lookout for companies, like BelliesAreUs, intent on cornering the market. If BelliesAreUs's inventory ever exceeds 10,000 lbs., which is over 50% of the entire bellies market, then the PBEC assesses a 10% surcharge on each subsequent purchase of pork bellies. Naturally, these surcharges decrease the assessed value of the inventory.

Store the values needed for the program in a data file named proj2.dta. The file format is as follows: the first two fields of each transaction record are the hour and minute of the day. Trading starts at 8 AM and ends at 5 PM. Times are in military format. The third field is the transaction code, and the fourth is the amount associated with the transaction. For codes of BEG, PUR and SAL, the amount is the weight of the pork bellies involved in the transaction. For PRC and UPD, it is a price per pound. For REQ transactions, the amount will be zero and can be ignored. PRCs and REQs do not count against the total number of transactions.

For example, the data file:

8 0 BEG 3500.25
8 0 PRC 0.95
8 01 REQ 0.0
10 15 UPD 0.75
10 30 PUR 2500
15 56 UPD 1.25
16 31 SAL 5000.16
indicates that the inventory started with 3500.25 lbs. of pork bellies on-hand valued at $0.95 per pound. At 8:01 AM, there is a request for a price. At 10:15, the price on the commodities market falls to $0.75 per pound. At 10:30, there is a purchase of 2500 lbs. of pork bellies. At 15:56, the price of pork bellies jumps to $1.25 per pound, which is followed at 16:31 with a sale of 5000.16 lbs. of bellies. Pretty exciting.

Given this sample data file, your output should appear in five columns as shown:

  T#             Description       Price      Pounds    Lbs. On-Hand
         Beginning Inventory                                 3500.25
               Opening Price        0.95
         Inventory Valuation     3325.24
                Price Update        0.75
   1                Purchase     1875.00     2500.00         6000.25
                Price Update        1.25
   2                    Sale     6250.20     5000.16         1000.09

            Ending Inventory                                 1000.09
              Total Lbs Sold                 5000.16
                 Total Sales     6250.20
            Total Surcharges        0.00

Transaction codes may be invalid, but you can assume that all of the other values in the data file are correct.

And finally, you should create an output file named proj2.out and write the information needed for the next day's processing. Construct your own data sets to test the various features of your program. I'll post the real data set on the Tuesday morning (2/20) before the project is due.

Instructions for Electronic Submission: At the top of the file containing your source code (i.e., the file containing the C++ instructions), place the following header comment, with the appropriate modifications:

//
// Project 2
// Name: <your name>
// SID: <last four digits of student ID>
// E-mail: <e-mail address>
// Instructor: Maloof
// TA: <TA's name>
// COSC 071-<section number>
//
// Description: <Describe your program>
//

All programs must run under UNIX and must compile using GNU g++. When you are ready to submit your program for grading, e-mail it to your TA using the last four digits of your student ID and the suffix ``.cc'' as the subject line.

For example, if the last four digits of your student ID is 1234, the name of your source file is proj2.cc, and your TA's e-mail address is ``imagoodta@georgetown.edu'', then you would type at the UNIX prompt:

gusun% mailx -s "1234.cc" imagoodta@georgetown.edu < proj2.cc
You are executing the mailx command. The -s option indicates that the string "1234.cc" is the subject heading. imgagoodta@georgetown.edu is the address to which the mail will be sent. The part ``< proj2.cc'' takes your source file and directs it into the mailx command.

You can also use pine to submit your project. After filling in the To and Subject fields, type the ^R command in the MESSAGE TEXT screen. Pine will ask for a file name, which it will then load as your message text. Type ^X to send the e-mail.

You must submit your project by e-mail before 5:00 P.M. on the due date. Late projects will be subject to a penalty.

If you need to include a message to you TA about your submission, then type the message as a comment in the program.

Once you've submitted your project, it is important to keep an electronic copy on a university machine (e.g., gusun or cssun) that preserves the modification date and time. If we lose your project or the e-mail system breaks, then we will need to look at the modification date and time of your project to ensure that you submitted it before it was due.