CMSC104, Summer 2004
Programming Project 3
Checking Account
Out: Thursday, July 8, 2004
Due: Thursday, July 15, 2004 before midnight
The Objective
This project is designed to give you practice working with functions.
It will give you also give you more practice working with while loops
and switch statments.
The Background
Most people keep their money in a checking account. There are two
basic operations performed on the checking accout. One operation is
to deposit money into the account and the other is to make a withdrawal
from the account.
The Task
Your job is to write a program that will simulate the behavior of
a checking account. You program should accept a beginning balance
from the user and then display a menu with four options. The menu
should have the four options shown in the sample output below.
The functions you will write, in addition to the main function,
are:
- void PrintGreeting (void); - This function prints an explanation
of the program to the user. You should assume the user knows nothing about
program and give a detailed explanation.
- void PrintMenu (void); - This functions displays the menu to the
screen
- float Withdrawal (float balance, float withdrawalAmt); - This
function takes the current balance and the amount to withdrawal.
It returns the new balance after the withdrawal is made.
- float Deposit (float balance, float depositAmt); - This function
takes the current balance and the amount to be deposited as arguments.
It returns the new balance after the deposit is made.
- void PrintSummary (int totalWithdrawals, int totalDeposits, float begBalance, float balance); -
This function prints an account summary to the screen.
It should list the total number of withdrawals, the total number of deposits,
the beginning balance and the ending balance. It does not have to match
the sample output exactly.
- int BelowMinBalance (float balance, float minimunBalance); - This
function takes the balance and the minimum required balance as arguments.
It checks the balance to see if it is below the minimum required checking
account balance. It returns a 1 if the balance is below the minimum or a
0 if it is not. It would probably be a good idea to use #defines for
0 and 1. We'll discuss this in class.
More Details
- The minimum required checking account balance is $500.00.
You should use the following symbolic constant:
#define MIN_BALANCE 500.00
- You should check the balance after every transaction
and print an appropriate error message if the balance goes
below the minimum.
Sample Output
linux3[1]% a.out
[Your greeting goes here.]
Please enter the beginning balance: 100.00
The beginning balance must be greater than or equal to 500.00.
Please enter the beginning balance again: 1000.00
1) Make a Withdrawal
2) Make a Deposit
3) Display Account Summary
4) Quit
Selection: 1
Enter the amount to withdrawal: 500.00
1) Make a Withdrawal
2) Make a Deposit
3) Display Account Summary
4) Quit
Selection: 1
Enter the amount to withdrawal: 100.00
****** Warning: Below minimum required balance ******
1) Make a Withdrawal
2) Make a Deposit
3) Display Account Summary
4) Quit
Selection: 3
----------------------------------------------------
Account Summary
Beginning balance: $1000.00
Ending balance: $400.00
Total number of withdrawals: 2
Total number of deposits: 0
----------------------------------------------------
1) Make a Withdrawal
2) Make a Deposit
3) Display Account Summary
4) Quit
Selection: 2
Enter the amount to deposit: 500.00
1) Make a Withdrawal
2) Make a Deposit
3) Display Account Summary
4) Quit
Selection: 3
----------------------------------------------------
Account Summary
Beginning balance: $1000.00
Ending balance: $900.00
Total number of withdrawals: 2
Total number of deposits: 1
----------------------------------------------------
1) Make a Withdrawal
2) Make a Deposit
3) Display Account Summary
4) Quit
Selection: 4
linux3[2]%
Submitting the Program
Here is a sample submission command. Note that the project name starts with uppercase 'P'.
submit cs104 Proj3 proj3.c
To verify that your project was submitted, you can execute the
following command at the Unix prompt. It will show the file that
you submitted in a format similar to the Unix 'ls' command.
submitls cs104 Proj3