Need help with your Discussion

Get a timely done, PLAGIARISM-FREE paper
from our highly-qualified writers!

glass
pen
clip
papers
heaphones

A code walk-thru, explaining significant pieces of functionality (Copy/ Paste CODE: Listed Below)

A code walk-thru, explaining significant pieces of functionality (Copy/ Paste CODE: Listed Below)

A code walk-thru, explaining significant pieces of functionality (Copy/ Paste CODE: Listed Below)

Question Description

• Create: short, simple side-notes that explains what happens during each line of code (Explanation Can be done in word)

• Run Program: in Matlab while screen recording (The “Demo Screen Recording”: should have No Sound and should be about 5-10 minutes in length) – This is only to show how the program works.

==============================================================================================================================================================

COPY/ PASTE the program listed – BELOW – into Matlab

===============================================================================

% Load information from account database file if file exists, otherwise

% Create new database.

filename = ‘AccountDatabase.mat’;

try

% Load file if it exists.

account = load(filename);

catch ME

% Create new account database.

% Map container variable to store all users account information

% Account number is key and struct container user info is value.

accountDB= containers.Map;

% Add two dummy users to account database

accountDB(‘001122’) = struct(‘firstName’, ‘John’, ‘lastName’, ‘Doe’, ‘balance’, 1000);

accountDB(‘997722’) = struct(‘firstName’, ‘Jane’, ‘lastName’, ‘Smith’, ‘balance’, 700);

end

%% Welcome prompt. Inquire if user have account or not.

% Create account if user is new.

while(true)

disp(‘Welcome to Student Bank’)

selection = getResponse(‘Do you have an account [Y/N]: ‘);

fprintf(“n”)

if (selection == ‘N’)

fprintf(“Okay. Let’s open a new account for you.n”)

data = createAccount(accountDB);

accountNumber = data{1};

accountDB = data{2};

fprintf(“nAccount created. nYour account number is: %sn”, accountNumber);

break

else

accountNumber = input(‘Enter your 6 digit account number: ‘, ‘s’);

if isKey(accountDB, accountNumber)

break

else

fprintf(‘Account not found. Try again.nn’)

end

end

end

%% Display Transaction options to the user.

fprintf(“nWelcome %s %sn”, accountDB(accountNumber).firstName, accountDB(accountNumber).lastName);

fprintf(“Account Balance: $%.2fn”, accountDB(accountNumber).balance);

prompt = ‘What would you like to do today?’;

while (true)

option = displayMenu(prompt);

if (option == 1)

accountDB = deposit(accountNumber, accountDB);

fprintf(“Deposit successful.n”)

printAccountBalance(accountNumber, accountDB, ‘New Account Balance is: ‘)

elseif (option == 2)

accountDB = withdraw(accountNumber, accountDB);

fprintf(“Withdrawal successful.n”)

printAccountBalance(accountNumber, accountDB, ‘New Account Balance is: ‘)

elseif(option == 3)

printAccountBalance(accountNumber, accountDB, ‘Account Balance: ‘)

elseif (option == 4)

save(filename, ‘accountDB’);

fprintf(“Thank you %s %s for banking with us.n”, accountDB(accountNumber).firstName, accountDB(accountNumber).lastName)

break

end

prompt = ‘Perform another transaction?’;

end

%% Function to print account balance.

function printAccountBalance(accountNumber, accountDB, prompt)

if accountDB(accountNumber).balance >= 0

fprintf(“%s$%.2fnn”, prompt, accountDB(accountNumber).balance);

else

fprintf(“%s-$%.2fnn”, prompt, abs(accountDB(accountNumber).balance));

end

end

%% Function to perform withdrawal transactions

function db = withdraw(accountNumber, accountDB)

overdraftFee = 35;

while(true)

try

withdrawAmount = input(‘Enter the amount to withdraw: ‘);

% Validate the entered amount

if (isnumeric(withdrawAmount))

if withdrawAmount > accountDB(accountNumber).balance

fprintf(“The amount you want to withdraw exceeds your account balance.n”)

printAccountBalance(accountNumber, accountDB, ‘Account Balance: ‘)

fprintf(“If you wish to continue, an overdraft fee of $%.2f would be charged to your account.n”, overdraftFee);

selection = getResponse(‘Do you wish to continue withdrawal [Y/N]: ‘);

if selection == ‘Y’

break;

else

disp(‘Please enter another amount to withdraw’);

end

else

break;

end

else

disp(‘Invalid input. Try again.’)

end

catch ME

fprintf(“Error: %sn”, ME.message);

end

end

accountDetails = accountDB(accountNumber);

if withdrawAmount > accountDetails.balance

accountDetails.balance = accountDetails.balance – withdrawAmount – overdraftFee;

else

accountDetails.balance = accountDetails.balance – withdrawAmount;

end

accountDB(accountNumber) = accountDetails;

db = accountDB;

end

%% Function to perform deposit transactions.

function db = deposit(accountNumber, accountDB)

while(true)

try

depositAmount = input(‘Enter deposit amount: ‘);

% Validate the entered amount

if (isnumeric(depositAmount) && depositAmount >= 0)

break;

else

disp(‘Invalid input. Enter a positive amount’)

end

catch ME

fprintf(“Error: %sn”, ME.message);

end

end

accountDetails = accountDB(accountNumber);

accountDetails.balance = accountDetails.balance + depositAmount;

accountDB(accountNumber) = accountDetails;

db = accountDB;

end

%% Function to create new bank account.

function newData = createAccount(accountDB)

firstName = input(‘Please enter your first name: ‘, ‘s’);

lastName = input(‘Please enter your last name: ‘, ‘s’);

% Generate new account number.

while (true)

accountNumber = ”;

for i = 1:6

accountNumber = strcat(accountNumber, num2str(randi(9)));

end

if (isKey(accountDB, accountNumber) == false)

break

end

end

newData{1} = accountNumber;

accountDB(accountNumber) = struct(‘firstName’, firstName, ‘lastName’, lastName’, ‘balance’, 0.0);

newData{2} = accountDB;

end

%% Function to display welcome menu to user.

function selection = getResponse(prompt)

while(true)

selection = upper(input(prompt, ‘s’));

if (selection == “YES” || selection == “Y”)

selection = ‘Y’;

break;

elseif (selection == “NO” || selection == “N”)

selection = ‘N’;

break

else

disp(‘Invalid input. Try again.’)

end

end

end

%% Function to display account transaction options

% user’s selection.

function option = displayMenu(prompt)

while(true)

disp(prompt)

disp(‘ 1: Deposit’)

disp(‘ 2: Withdraw’)

disp(‘ 3: Check Account Balance’)

disp(‘ 4: Exit’)

fprintf(“n”)

try

option = input(‘Enter selection: ‘);

if isnumeric(option) && (option == 1 || option==2 || option==3 || option==4)

break

else

disp(‘Invalid input. Try again’)

end

catch ME

fprintf(“Error: %sn”, ME.message);

end

end

end

Have a similar assignment? "Place an order for your assignment and have exceptional work written by our team of experts, guaranteeing you A results."

Order Solution Now

Our Service Charter


1. Professional & Expert Writers: Eminence Papers only hires the best. Our writers are specially selected and recruited, after which they undergo further training to perfect their skills for specialization purposes. Moreover, our writers are holders of masters and Ph.D. degrees. They have impressive academic records, besides being native English speakers.

2. Top Quality Papers: Our customers are always guaranteed of papers that exceed their expectations. All our writers have +5 years of experience. This implies that all papers are written by individuals who are experts in their fields. In addition, the quality team reviews all the papers before sending them to the customers.

3. Plagiarism-Free Papers: All papers provided by Eminence Papers are written from scratch. Appropriate referencing and citation of key information are followed. Plagiarism checkers are used by the Quality assurance team and our editors just to double-check that there are no instances of plagiarism.

4. Timely Delivery: Time wasted is equivalent to a failed dedication and commitment. Eminence Papers are known for the timely delivery of any pending customer orders. Customers are well informed of the progress of their papers to ensure they keep track of what the writer is providing before the final draft is sent for grading.

5. Affordable Prices: Our prices are fairly structured to fit in all groups. Any customer willing to place their assignments with us can do so at very affordable prices. In addition, our customers enjoy regular discounts and bonuses.

6. 24/7 Customer Support: At Eminence Papers, we have put in place a team of experts who answer all customer inquiries promptly. The best part is the ever-availability of the team. Customers can make inquiries anytime.

We Can Write It for You! Enjoy 20% OFF on This Order. Use Code SAVE20

Stuck with your Assignment?

Enjoy 20% OFF Today
Use code SAVE20