Practice Problem 4: Bank Charges
Objective: To calculate bank charges and verify input using if-statements
Please do Programming Challenge #6 at the end of Chapter 4 (page 212). Here's my brief summary of the
book's description:
- A bank charges $10 per month plus:
- $0.10 for each check if you write less than 20 checks
- $0.08 for each check if you write between 20-39 checks
- $0.06 for each check if you write between 40-59 checks
- $0.04 for each check if you write 60 or more checks
- The bank also charges $15 if the balance falls below $400 (before any fees are applied - a slight
change/clarification
from the book's description)
- If the user enters a negative number of checks,
output an error message and don't calculate any check fees. If a negative value is given for the beginning
balance,
display an urgent message indicating the account is overdrawn, but still calculate fees.
- The book doesn't say what to do if fees make it overdrawn. What do you think should be done? Personally,
I think a
message indicating so would be a good idea. But this is not required.
Your program should behave like shown below (remember that "bash-2.04$" is the Unix prompt; your program
does not output this)
Compilation and Sample Input/Output on Unix:
bash-2.04$ aCC -AA lab2.cpp
bash-2.04$ a.out
Enter the following information about your checking account.
Beginning balance: $1000
Number of checks written: 50
The bank fee this month is $13.00
bash-2.04$ a.out
Enter the following information about your checking account.
Beginning balance: $405.25
Number of checks written: 5
The bank fee this month is $10.50
bash-2.04$ a.out
Enter the following information about your checking account.
Beginning balance: $100.05
Number of checks written: 100
The bank fee this month is $29.00
bash-2.04$ a.out
Enter the following information about your checking account.
Beginning balance: $-5
Number of checks written: -10
Your account is overdrawn!
Number of checks must be zero or more.
bash-2.04$
Rules
- Save both the source code and the output it produced after you compiled and ran it. You should save these in a
plain
text file with a file extension of either .txt or .cpp.
- Put comments at the top of your program with your name, the name of your C++ source file, the name of this
assignment
and class (CS 110A Practice Problem 4), and a brief description of what the program does. Format it so that it is
readable and
professional.
- Follow the standard conventions for indentation, meaningful variable names, etc. like the textbook.
- The output should show the above test cases.