This assignment will give you practice w/user and program interfaces,
and choosing/building useful data structures.
You will maintain a flat-file log, essentially, allowing users to query,
and add an entry.
Write a command-line utility called accounts that uses
what is, essentially a log file, list of transactions (deposits and
The account number will be the primary key; that is, no 2 accounts may
have the same account number. 2 different accounts may, however,
have the same name. (E.g., you may have a checking account, and a savings
You will allow the user to view account info, and history, and to add
transactions, as follows:
Options, and Descriptions
- -i — Account info
- Display an enumerated, alphabetical list of
account holders, followed by the account number
(Note, these lines should be unique)
- You will allow the user to choose an account by entering the
number, or to quit by entering a q
- You will then list account info:
- Account #
- Account holder's name
- Prompt to return to the list of account holders (so the user has
time to read the output)
- -h — History
- Display the same account menu as above
- Allow the user to choose an account by entering the
number, or to quit by entering a q
- If an account is selected, list all the transactions for that
account, in chronological order (you may assume the transactions in
the input file are in chronological order). You will print, on one
line, the date, the type (deposit or withdrawal), and the amount
- -t — Insert transaction
- Again, get an account choice, as above, with an option to create
a new account (be careful that the account # doesn't already exist)
- Then prompt for:
- Type (withdrawal or deposit), using simple keystrokes
(w or d, followed by [enter])
- The amount
- Use the current day's date
- Return to the choose-account menu
- -? — Show usage msg and quit
You may assume that all names are entered exactly.
That is, do not worry about inconsistencies in spelling or capitalisation.
E.g., John Doe, Jonathon Doe, and john doe are 3
different clients for this assignment. Further, for purposes of
alphabetising, take the name to be that single string. Don't attempt to
extract first, last name information.
If no argument is supplied, print a usage message and exit.
Account information will be stored in a flat file w/the format shown in sample.log:
Each line contains the account # (a string of 4 numbers), the account
holder's name, the date (YY.MM.DD), the transaction type, and the amount,
separated by colons.
To simplify things, the filename (location of the log) will be stored in
an exported environment variable, $ACCT_LIST .
You can do this in any language you choose, including Bash or AWK. The
language must be currently hosted on the tux machines.
If you, e.g., do this in Java, then you'll need to supply a shell script
called accounts that invokes your program, the JRE, whatever,
- I'd create some data structure to represent a transaction
- Use some dictionary, or map, to store accounts
- Group transactions together, under the account
- When updating the DB (writing the new file out), write to a temporary
file. If this is successful, rename it appropriately. This is
generally an atomic operation. So, if something bad happens w/your
program, or the power grid, etc., you don't blow your DB up
Since you can do this in a number of languages, submit a makefile .
I've provided templates:
sample Python makefile
sample Java makefile
sample C++ makefile
See my notes on makefiles for help.
Submit the following files.
- makefile - your makefile, with the folowing targets:
- build — compile your code, whatever, get it ready
- clean — cleans up all intermediate and resulting
- view — display any source code that you wrote, in
- all of your source files. Binaries and other
compiled code (.class, .o, executables) will be
deleted before I start, so, must be built from source.
- README optional - anything you want to say to
me before I grade.
Please note: You will use the filenames as listed
here, and submit them all to the proper assignment. If this is not
clear, then see me in class. If I get programs submitted to the wrong
directories, I will be irate, which may, in some subconscious way, affect
your grades. Adversely.