CMSC 201
Programming Project One
The ATM
Out: Sunday 2/18/01
Due: Before Midnight, Sunday 2/25/01
|
The Objective
The objective of this assignment is to get you started writing programs
in C in the UNIX environment. Its main emphasis is design, so we will be
designing the project together in class. You should keep in mind all of the
design techniques that we've covered in class, including top-down design,
writing functions that do only one thing, writing functions to be general, and
using symbolic constants instead of having "magic numbers" within your code.
This project will also give you practice writing functions, loops, switch
statements and using seperate compilation.
The Background
We are all familiar with ATMs. They allow us to have access to our
bank accounts by entering a PIN. We are then allowed to perform
functions such as depositing or withdrawing money from either our checking or
savings accounts, transferring money between the accounts, or we may simply
check our balances.
In this project we will simulate some of the functions of an ATM.
Since there are no real checking or savings accounts that we need to protect,
we need not worry about entering a PIN. To get started though, we
will need to explain the program to the user and ask him/her to input the
amounts that will be used as the beginning balances for the checking and
savings accounts. After that we can begin to simulate the ATM by presenting
the user with a menu of banking choices.
The choices available to the user are :
- Deposit to Checking
- Deposit to Savings
- Transfer from Checking to Savings
- Transfer from Savings to Checking
- Withdraw from Checking
- Withdraw from Savings
- Show Balances
- Quit
Banking Rules:
- You may never allow the user to have a negative balance in any account.
If the user has asked to withdraw more money from an account than
its current balance, then you should inform the user what the maximum
amount is that s/he can withdraw and prompt the user for a new amount.
- Do not allow a beginning balance of over $ 100,000.00 for either
account, since that is the maximum amount that is insured by the FDIC.
If the user chooses to deposit funds later that take his balances above
the $ 100,000 point, he does so at his own risk and your program should
not stop him from doing so. You should not allow a single deposit of
over $ 100,000.00, however.
The Task
Design (to be done in class) and code a project that after printing a greeting
to the user, presents the user with a menu and allows him to choose to
deposit to checking or savings, transfer money between accounts, withdraw from
checking or savings, or show the balances of the accounts. After accomplishing
the requsted task, the user should be presented with the menu again, so that
s/he can continue to make choices.
After the user has chosen quit, s/he should be presented with the updated
account balances and be informed of how many transactions were completed during
the session. A transaction is defined to be either a deposit, withdrawal, or
transfer of funds where the amount was greater than $ 0.00.
Since you are distributing this software to others, you must use seperate
compilation and provide the interface for the user. The interface is to be
in the form of a well-commented header (.h) file.
Sample Run
[102] a.out
This is where the Greeting would go
Beginning balance for the Checking Account
Please enter the amount: 500.00
Beginning balance for the Savings Account
Please enter the amount: 130000.00
Sorry, the amount must be between 0.00 and 100000.00
Please enter the amount: 4000.00
1 - Deposit to Checking
2 - Deposit to Savings
3 - Transfer from Checking to Savings
4 - Transfer from Savings to Checking
5 - Withdraw from Checking
6 - Withdraw from Savings
7 - Show Account Balances
8 - Quit
Enter your choice : 1
Deposit to Checking:
Please enter the amount: 250.45
1 - Deposit to Checking
2 - Deposit to Savings
3 - Transfer from Checking to Savings
4 - Transfer from Savings to Checking
5 - Withdraw from Checking
6 - Withdraw from Savings
7 - Show Account Balances
8 - Quit
Enter your choice : 2
Deposit to Savings:
Please enter the amount: 1000.00
1 - Deposit to Checking
2 - Deposit to Savings
3 - Transfer from Checking to Savings
4 - Transfer from Savings to Checking
5 - Withdraw from Checking
6 - Withdraw from Savings
7 - Show Account Balances
8 - Quit
Enter your choice : 3
Transfer from Checking to Savings:
Please enter the amount: 100.00
1 - Deposit to Checking
2 - Deposit to Savings
3 - Transfer from Checking to Savings
4 - Transfer from Savings to Checking
5 - Withdraw from Checking
6 - Withdraw from Savings
7 - Show Account Balances
8 - Quit
Enter your choice : 4
Transfer from Savings to Checking:
Please enter the amount: 300.00
1 - Deposit to Checking
2 - Deposit to Savings
3 - Transfer from Checking to Savings
4 - Transfer from Savings to Checking
5 - Withdraw from Checking
6 - Withdraw from Savings
7 - Show Account Balances
8 - Quit
Enter your choice : 5
Withdraw from Checking:
Please enter the amount: 15.10
1 - Deposit to Checking
2 - Deposit to Savings
3 - Transfer from Checking to Savings
4 - Transfer from Savings to Checking
5 - Withdraw from Checking
6 - Withdraw from Savings
7 - Show Account Balances
8 - Quit
Enter your choice : 6
Withdraw from Savings:
Please enter the amount: 250.00
1 - Deposit to Checking
2 - Deposit to Savings
3 - Transfer from Checking to Savings
4 - Transfer from Savings to Checking
5 - Withdraw from Checking
6 - Withdraw from Savings
7 - Show Account Balances
8 - Quit
Enter your choice : 7
Checking Account Balance: $ 935.35
Savings Account Balance: $ 4550.00
1 - Deposit to Checking
2 - Deposit to Savings
3 - Transfer from Checking to Savings
4 - Transfer from Savings to Checking
5 - Withdraw from Checking
6 - Withdraw from Savings
7 - Show Account Balances
8 - Quit
Enter your choice : 10
10 is not a valid response
1 - Deposit to Checking
2 - Deposit to Savings
3 - Transfer from Checking to Savings
4 - Transfer from Savings to Checking
5 - Withdraw from Checking
6 - Withdraw from Savings
7 - Show Account Balances
8 - Quit
Enter your choice : 8
You performed 6 transactions
Checking Account Balance: $ 935.35
Savings Account Balance: $ 4550.00
Thank you for dealing with B & B's Friendly Bank !
[103]
Although your output need not be identical to the above,
all information (including the greeting) must be present.
Please be aware that this is definitely NOT a complete
test of the program. Your testing should be much more extensive.
Submitting the Program
You are to use seperate compilation for this project, so you will be
submitting three files.
Your C source code file that contains main() MUST be called
proj1.c. The file which contains the function definitions
MUST be called atm.c and the header file MUST be
called atm.h
To submit your project, type the following at the Unix prompt.
Note that the project name starts with uppercase 'P'.
submit cs201 Proj1 proj1.c atm.c atm.h
To verify that your project was submitted, you can execute the
following command at the Unix prompt. It will show all files that
you submitted in a format similar to the Unix 'ls' command.
submitls cs201 Proj1