Title: Checkbook Balancing Revisited
Course: Programming Fundamentals II (TEMPLATE)

COSC 1337 - Programming Fundamentals II

Assignment 3 - Checkbook Balancing Revisited

Read through Chapter 6 in your textbook before starting this assignment.

Modify your checkbook balancing program from assignment 2 as follows:

- The user should enter the transaction type and amount (if required) on a single line. If there is a problem with the command (invalid transaction type or invalid amount), print an error message and have the user re-enter the whole command. You should never have a separate prompt for just the transaction type or for just the transaction amount. Note that this means that you do not need a validation loop. You just need a loop that reads a command on each iteration.
- Use a separate function to do check processing and another function to do deposit processing.
- Add additional service charges (see below).

The program commands are as follows (see the sample program dialog near the bottom of this page).

Transaction command | Meaning
C amount | Process a check for amount dollars, where amount is a floating-point number.
D amount | Process a deposit for amount dollars, where amount is a floating-point number.
E | End the program.

Service Charges

- There is a $0.25 service charge for each check written.
- If the account balance falls below $800.00 at any time during the month, there is a $5.00 service charge for the month. NOTE: This fee is only charged once at most!
- If processing a check results in a negative balance, there is a $25 service charge (insufficient funds charge). This $25 fee is charged for each check that results in a negative balance.
- Note: all service charges should be deducted from the account balance at the end of the month.

Output

For each transaction, print

- the command data (to confirm the transaction)
- the resulting account balance
- the total service charges accrued so far

At the end of the month, deduct the service charges and print the final balance. Your program dialog should look something like this example (user input is shown in bold).

Enter the beginning balance: 900

Enter a transaction: C 50.25
Processing check for $50.25
Balance: $849.75
Service charge: $0.25 for a check
Total service charges: $.25

Enter a transaction: C 250
Processing check for $250.00
Balance: $599.75
Service charge: $0.25 for a check
Service charge: $5.00 balance below $800.00
Total service charges: $5.50

Enter a transaction: D 200
Processing deposit for $200.00
Balance: $799.75
Total service charges: $5.50

Enter a transaction: E
Processing end of month
Final balance: $794.25

Other requirements

- Do not use global variables in any assignment. A global variable is a variable that is declared outside any function.
- All input should be checked for reasonable values.
- All dollar amounts should be printed with 2 decimal places.
- Write a separate function to process each of the transaction types (check or deposit).

© Austin Community College 2016. The content on this page is licensed under a
Creative Commons Attribution 4.0 International License.
Last updated: February 8, 2016