Question
MATLAB You were just hired by a bank in the area to fix a buggy program written by a since fired programmer. This function is
MATLAB
You were just hired by a bank in the area to fix a buggy program written by a since fired programmer. This function is supposed to do the following:
*Receive a method (withdraw, deposit, or balance)
*Perform the respective operation and return the current account balance
*If the withdrawal amount exceeds the balance, cancel the transaction and return the balance
The account balance should persist between function calls. For example, if you did the following:
>> bankingsystem('d', 10000) % deposit 10,000 ans = 10000 >> bankingsystem('w', 5000) % withdraw 5,000 ans = 5000 >> bankingsystem('b', 0) % the amount doesn't matter when getting the balance ans = 5000 >> bankingsystem('w', 10000) % the account is overdrawn! ans = 5000
The main function header, bankingsystem() has been written for you and it is up to you to fix the issues so this bank can be up and running again!
function balance = bankingsystem(mode, amount)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started