14. Bank Charges A bank charges $10 per month plus the following check fees for a commercial checking account: $.10 each for fewer than 20 checks $.08 each for 20-39 checks $.06 each for 40-59 checks $.04 each for 60 or more checks The bank also charges an extra $15 if the balance of the account falls below $400 (before any check fees are applied). Write a program that asks for the beginning bal- ance and the number of checks written. Compute and display the bank's service fees for the month.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

C++

Also prompt the user for the total amount deposited. Do not accept a value less than zero; display an error message and exit the program if this occurs.

If the number of checks entered is greater than zero, prompt the user for the total amount of the checks written. Do not accept a value of zero or less; provide an error message and exit if the user enters invalid data.

We will also bring this problem into the 21st century and consider ATM transactions as well. Prompt the user for the number of ATM transactions. Like number of checks written, do not accept a negative number here. If the number of transactions is greater than zero, also prompt for the total amount withdrawn. Do not accept zero or less for that total amount. The first five ATM transactions are free; charge a dime for each subsequent transaction.

If the balance after charges and withdrawals are applied but before the deposit is credited is less than the minimum balance of 400.00, charge them the low balance fee. Yes, banks actually do it that way. If that balance is less than zero display an "overdrawn" notice and charge them an additional "overdrawn fee" of $20. 

Show your results as a vertical table, using appropriate formatting. All dollar amounts should be shown with exactly two digits after the decimal, and aligned by the decimal point in the table. Counts (like the number of checks written) should be integers. Include lines for the initial balance, the monthly charge, the number of checks written (if not zero) and the check charge and the checks written amount, the number of ATM transactions (if not zero) and the ATM charge and amount withdrawn, the final balance at this point, the low balance fee (if applied), the overdrawn fee (if applied), the amount deposited, and the final balance. 

For your screen shot, enter an initial balance of 365.50, a deposit total of of 208.56, 22 checks written for a total of $410.55, and 7 ATM transactions for a total of $240. But in your testing make sure you first enter invalid values at every opportunity to demonstrate your program's ability to catch those errors.

### Bank Charges

A financial institution charges $10 per month for maintaining a commercial checking account. In addition to this base fee, the bank also imposes service charges for processing checks as follows:

- $0.10 for fewer than 20 checks
- $0.08 for 20–39 checks
- $0.06 for 40–59 checks
- $0.04 for 60 or more checks

Additionally, if the account balance falls below $400 (before any check fees are applied), an extra charge of $15 is levied.

#### Program Instructions:

Develop a program that:

1. Prompts the user to input the beginning balance of the account.
2. Asks for the number of checks written.
3. Computes and displays the bank’s service fees for the month.

This program should accurately calculate the total cost incorporating the base fee, per-check charges, and any additional low-balance penalty if applicable.
Transcribed Image Text:### Bank Charges A financial institution charges $10 per month for maintaining a commercial checking account. In addition to this base fee, the bank also imposes service charges for processing checks as follows: - $0.10 for fewer than 20 checks - $0.08 for 20–39 checks - $0.06 for 40–59 checks - $0.04 for 60 or more checks Additionally, if the account balance falls below $400 (before any check fees are applied), an extra charge of $15 is levied. #### Program Instructions: Develop a program that: 1. Prompts the user to input the beginning balance of the account. 2. Asks for the number of checks written. 3. Computes and displays the bank’s service fees for the month. This program should accurately calculate the total cost incorporating the base fee, per-check charges, and any additional low-balance penalty if applicable.
### Input Validation Guidelines

When designing software or systems that involve financial transactions, input validation is crucial for ensuring data integrity and preventing errors. Below are essential guidelines for validating user input related to checks and account balances:

1. **Do not accept a negative value for the number of checks written.**
   - Rationale: The number of checks written should always be a non-negative integer as writing negative checks is illogical and indicative of an error.

2. **If a negative value is given for the beginning balance, display an urgent message indicating the account is overdrawn.**
   - Rationale: A negative beginning balance signifies that the account is overdrawn and appropriate steps need to be taken to address this issue. Informing the user immediately helps in managing their account responsibly and avoiding further complications.

### Example Implementation

Here is a sample code snippet that demonstrates how you might implement the above input validation in a programming context:

```python
def validate_inputs(num_checks, beginning_balance):
    if num_checks < 0:
        raise ValueError("The number of checks written cannot be negative.")
    
    if beginning_balance < 0:
        print("Urgent: Your account is overdrawn.")
    else:
        print("Account balance is within the acceptable range.")

# Example usage:
num_checks_written = -5
beginning_balance = -100

try:
    validate_inputs(num_checks_written, beginning_balance)
except ValueError as e:
    print(e)
```

In this example, if the user inputs a negative number of checks or a negative beginning balance, the system will handle these inputs appropriately by either raising an error or printing an urgent message.

### Importance of Input Validation

Input validation helps:
- **Prevent Data Corruption:** Ensures that only valid and logical data is processed.
- **Enhance Security:** Reduces risks related to invalid user inputs, potentially preventing exploits.
- **Improve User Experience:** Provides immediate feedback, guiding users toward correct input.

Adhering to stringent input validation rules is a best practice in software development, particularly in financial applications, where accuracy and reliability are paramount.
Transcribed Image Text:### Input Validation Guidelines When designing software or systems that involve financial transactions, input validation is crucial for ensuring data integrity and preventing errors. Below are essential guidelines for validating user input related to checks and account balances: 1. **Do not accept a negative value for the number of checks written.** - Rationale: The number of checks written should always be a non-negative integer as writing negative checks is illogical and indicative of an error. 2. **If a negative value is given for the beginning balance, display an urgent message indicating the account is overdrawn.** - Rationale: A negative beginning balance signifies that the account is overdrawn and appropriate steps need to be taken to address this issue. Informing the user immediately helps in managing their account responsibly and avoiding further complications. ### Example Implementation Here is a sample code snippet that demonstrates how you might implement the above input validation in a programming context: ```python def validate_inputs(num_checks, beginning_balance): if num_checks < 0: raise ValueError("The number of checks written cannot be negative.") if beginning_balance < 0: print("Urgent: Your account is overdrawn.") else: print("Account balance is within the acceptable range.") # Example usage: num_checks_written = -5 beginning_balance = -100 try: validate_inputs(num_checks_written, beginning_balance) except ValueError as e: print(e) ``` In this example, if the user inputs a negative number of checks or a negative beginning balance, the system will handle these inputs appropriately by either raising an error or printing an urgent message. ### Importance of Input Validation Input validation helps: - **Prevent Data Corruption:** Ensures that only valid and logical data is processed. - **Enhance Security:** Reduces risks related to invalid user inputs, potentially preventing exploits. - **Improve User Experience:** Provides immediate feedback, guiding users toward correct input. Adhering to stringent input validation rules is a best practice in software development, particularly in financial applications, where accuracy and reliability are paramount.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education