Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need the C++ code for the following program: Instructions to Exercise 20 of Chapter 1 have been posted below for your convenience. Exercise 20

I need the C++ code for the following program:

Instructions toExercise 20ofChapter 1have been posted below for your convenience.

Exercise 20 (Assume that the account balance is stored in the fileCh4_Ex15_Data.txt.)

An ATM allows a customer to withdraw a maximum of $500 per day. If a customer withdraws more than $300, the service charge is 4% of the amount over $300. If the customer does not have sufficient money in the account, the ATM informs the customer about the insufficient funds and gives the customer the option to withdraw the money for a service charge of $25.00. If there is no money in the account or if the account balance is negative, the ATM does not allow the customer to withdraw any money. If the amount to be withdrawn is greater than $500, the ATM informs the customer about the maximum amount that can be withdrawn. Write an algorithm that allows the customer to enter the amount to be withdrawn. The algorithm then checks the total amount in the account, dispenses the money to the customer, and debits the account by the amount withdrawn and the service charges, if any.

Your program should output account balance before and after withdrawal and service charges. Also save the account balance after withdrawal in the fileCh4_Ex15_Output.txt.

Ensure the output inCh4_Ex15_Output.txtis accurate to two decimal places.

Analyze the requirements

  1. We need to know how much money the customer wishes to withdraw -> Ask the user to enter the amount to be withdrawn
  2. We need to know how much money the account holds -> Read the account balance from the database
  3. We need to determine if a withdrawal is allowed at all based on the amount to be withdrawn (amount $500). If it isn't allowed, inform the customer about the maximum amount.
  4. We need to determine if a withdrawal is allowed at all based on the account balance (balance > 0) . If it isn't allowed, inform the customer.
  5. We need to calculate the service charge for amounts over $300
  6. We need to calculate the service charge for insufficient funds
  7. We need to calculate the total account debits by adding the service charge for amounts over $300, the service charge for insufficient funds, and the withdrawal amount
  8. If allowed, we need to tell the machine to output the withdrawal amount
  9. We need to subtract the total account debits from the current account balance and save the new account balance to the database
  10. We need to inform the user what the starting balance is
  11. We need to inform the user what the service charges are
  12. We need to inform the user what the ending balance is

Design the algorithm to accomplish the requirements

  1. Get the withdrawal amount from the user
  2. Input the account balance from the data file
  3. Compare the withdrawal amount with $500
    1. If the withdrawal amount is greater than $500, display a message to the user that the maximum amount is $500 (we still need to output the balances)
  4. Compare the account balance with $0
    1. If the account balance is less than or equal to $0, display a message to the user that they do not have any funds to make a withdrawal and end the program
  5. Compare the withdrawal amount with $300
    1. If the withdrawal amount is greater than $300, calculate the over $300 service charge as 0.04 * (withdrawal amount - 300)
  6. Compare the withdrawal amount with the account balance
    1. If the withdrawal amount is greater than the account balance
      1. Display a message to the user that they do not have sufficient funds and that they will be charged $25 if they continue and ask the user if they wish to continue.
      2. Get the response from the user
      3. If they respond "no" end the program.
      4. Otherwise, calculate the insufficient funds service charge as $25
  7. Calculate total account debits as withdrawal amount + over $300 service charge + insufficient funds service charge and save as total debit.
  8. Send a message to the machine to dispense the withdrawal amount.
  9. Subtract the total debit from the account balance and save the new account balance to the output file
  10. Display the account balance before the withdrawal
  11. Display the account balance after the withdrawal
  12. Display the total service charges

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions