Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1 . Only the algorithm is needed An ATM allows a customer to withdraw a maximum

ID: 3543760 • Letter: 1

Question

1.       Only the algorithm is needed 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 fund and gives 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.

Explanation / Answer

1. Take input from the user, asking for the amount to be withdrawn, and store in in float variable A. If A is greater than 500, display "Maximum withdrawal of $500.00 allowed." and exit the program. Or else, continue. If A is greater than 300, store 0.04*(300-A) in sc (float variable). Or else sc = 0.

2. Check the total amount of money in user's account (the information regarding his balance must be provided somehow).

3. If the balance is less than or equal to 0, the ATM displays the balance and says "Transaction Error".

4. If the balance is less than (A+sc), the ATM displays the balance and says "A service charge of $25.00 is required for the transaction. Type '1' to continue or '0' to cancel."

5. Store the input in a integer variable called 'flag'.

6. If flag is 1, give the user A, store sc+25.0 in sc and set new balance to balance-A-sc.

7. Else if flag is 0, exit program.

8. If balance is greater than or equal to newA, give the user amount A and set new balance to balance-A-sc.

9. Exit program.