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

Problem 1) Write a MATLAB script that would simulate a user-interface for an Aut

ID: 3602006 • Letter: P

Question

Problem 1) Write a MATLAB script that would simulate a user-interface for an Automated Teller Machine (ATM), When it first executes, it should ask the user to enter a PIN. You may have this PIN stored as a variable in the system. If the user fails to enter the PIN correctly in 3 attempts, it should inform the user that the bank card they have entered is being destroyed, ending the program/loop. After entering the correct PIN, it should then present the user with options to 1) Deposit Funds 2) Withdrawal Funds 3) View Balance 4) Exit Note - use a switch/case structure for this section. You may want to use fprintf and input combined to make a menu with descriptions as above. Each selection should then allow the user to input an amount of money to add/subtract from their balance based on user inputs... or view the balance.

Explanation / Answer

Please find the script below:

balance = 500;
count = 0;
pin = input('Enter PIN ');
while(pin ~= 1234)
count = count + 1;
fprintf('Incorrect pin entered ');
if(count == 3)
fprintf('Bank card destroyed ');
break;
end
pin= input('Enter PIN ');
end
if( count < 3)
c = menu('1. Deposit Funds',
'2. Withdrawal Funds',
'3. View Balance',
'4.Exit');
switch c
case 1
x = input('Add how much?');
if(x>0) balance = balance+x;
fprintf('Your available balance is %.2f ', balance);
end
case 2
x = input('Withdraw how much?');
if(balance>=x) balance = balance-x;
fprintf('Your available balance is %.2f ', balance);
else
error('Insufficient Funds');
end
case 3
fprintf('Your balance is %.2f ', balance);
case 4
break;
end
end

Output:


$octave -qf --no-window-system demo.m

EnterPIN 9987

Incorrectpin entered

EnterPIN 6666

Incorrectpin entered

EnterPIN 1234

1. Deposit Funds [ 1] 2. Withdrawal Funds [ 2] 3. View Balance [ 3] 4.Exit

Selecta number: 1

Addhow much? 599

Youravailable balance is 1099.00

warning: function ./demo.m shadows a core library function

Thanks.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote