UMBC CS 201, Fall 99
UMBC CMSC 201 Fall '99 CSEE | 201 | 201 F'99 | lectures | news | help

CMSC 201
Programming Project Five

F & B Lottery
Agent Accounting

Out: Monday 11/29/99
Due: Before Midnight, Tuesday 12/14/99


    The purpose of this project is to give you practice reading data from files, learning about structures and implementing the linked list ADT.


    One of the primary functions of any transaction processing system such as a lottery is accounting -- tracking the number and amount of every transaction processed. A lottery system must be able to account for every dollar wagered and every dollar paid out to the public.  Each person that operates a lottery ticket issuing machine is called an "agent".  Agents are identified by a unique 4-digit number. Agents perform three types of transactions:
      Wagers -- A player makes a wager and pays the cost of the ticket (like we calculated in project 1) to the agent.
      Cashes -- If a player wins, the agent pays the player the winning amount (like we calculated in project 4).
      Cancels -- Sometimes a player makes a wager and pays the agent, then changes his mind.  The agent cancels the ticket and refunds the cost of the ticket to the player.
    Accounting information is accumulated for each agent and for each game for each agent and for each transaction type.

The Task

The F & B Lottery (a competitor of the B & F Lottery) performs its agent accounting function by reading transactions from a file, then printing a summary of the transactions in the file. Your program will perform these two functions.  First, it will read and process a file with transaction data.  Second, it will display a summary of the transaction data by agent, game and transaction type.

Processing transactions

Your program reads transactions from a file and updates the accounting information for the agent that performed the transaction, the game to which the transaction applies and the transaction type.  The transactions in the file are specified below.   There will be one transaction per line.  The fields for each transaction will be separated by a space.  There may be any number of transactions in the file.  There will be no more than 5 agents.

          Transaction format

Agent Reporting

After reading and processing the file your program will present the user with a summary of the accouting information.  For each agent, your will report the number of wager, cash and cancel transactions for each game, the amount of wager, cash and cancel transactions for each game and a total for all games.  Your summary will also show the total for all agents. See the sample ouput below.  Although your report need not match the format of the sample output, the data must match exactly.

    Other Program Notes

Other Program Requirements

    1. Your program must use a linked list (see program hints)
    2. Your program must be in multiple .c files, one of which must be proj5.c which contains main().  You may create as many .c files as you feel are required.  Each .c file (except proj5.c) must have its interface defined in a similarly named .h file
    3. The file name of transactions must be entered as a command line argument
    4. Your program must check the number of command line arguments.  If incorrect, your program should provide a friendly message informing the user of the correct way to run your program.
    5. You may assume that all fields in all transactions are valid.

    Program hints

    This program requires use of a linked list.  This list should link together strutctures that hold accounting data for each game.  The head of the list is a structure that identifies the agent.  Since the maximum number of agents has been specified, it is possible to use an array of these structures.

The following diagram shows the array of agent structures and linked lists of game accounting structures

Sample Output

The sample output below was created by processing the file
While your output format does not have to match exactly, the data should match exactly.
[102] a.out p5.txt
Agent  Game NrWagers WagerAmt NrCashes CashAmt NrCancels CancelAmt
-----  ---- -------- -------- -------- ------- --------- ---------
 1234 Pick3        2     7.00        2    8.00         3      6.00  
      Pick4        2     9.00        3   18.00         2      2.00
      Lotto        1     6.00        5    6.00         4     15.00
 AGT TOTALS        5    22.00       10   32.00         9     23.00

 1357 Pick3        4    32.00        2  108.00         2     10.00 
      Pick4        2    22.00        5  191.00         3     29.00 
      Lotto        2    20.00        3 1011.50         1      5.00 
 AGT TOTALS        8    74.00       10 1310.50         6     44.00 

 2468 Pick3        6    62.00        2    7.00         5     36.00 
      Pick4        1     5.00        7  295.00         2      6.00 
      Lotto        0     0.00        1   65.00         2      3.00 
 AGT TOTALS        7    67.00       10  367.00         9     45.00 

 RPT TOTALS       20   163.00       30 1709.50        24    112.00


Submitting Your Program

    Submit your program in the usual way.  Be sure to submit all .c and .h files.  All files can be submitted at the same time by listing all the files on the command line when executing submit, as in the following

    submit cs201 Proj5 proj5.c <list of other files>

    Alternatively, you can submit each file separately.  As usual, be sure to verifiy your submittal with the submitls command.

This is the last project of the semester.  As with project 4, there is no excuse for having problems with submit.
There is no mercy at this point in the semester.