Question

Question #5. Write a script that creates a variable called BALANCE that is assigned the value 100.00. Then prompt the user toPlease provide MATLAB code and comments! Please provide MATLAB code and comments! Please provide MATLAB code and comments!

0 0
Add a comment Improve this question Transcribed image text
Answer #1
BALANCE = 100.00;   % initialize BALANCE to 100.00
WITHDRAW = input("Enter an amount to withdraw: ");  % prompt user for withdraw amount

BALANCE = BALANCE - WITHDRAW;   % withdraw "WITHDRAW" amount from BALANCE
if BALANCE < 0  % if remaining balance is negative
    fprintf("$%.2f withdrawal would produce a negative balance.\n", WITHDRAW) % then report error message
else    % if remaining balance is non-negative
    fprintf("Withdrawal Successful. Balance now $%.2f\n", BALANCE)  % then report remaining balance
end

Enter an amount to withdraw: > 99.99 Withdrawal Successful. Balance now $0.01

Add a comment
Know the answer?
Add Answer to:
Please provide MATLAB code and comments! Please provide MATLAB code and comments! Please provide MATLAB code...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Looking for code in MATLAB: A store owner asks you to write a program for use...

    Looking for code in MATLAB: A store owner asks you to write a program for use in the checkout process. The program should: Prompt the user to enter the cost of the first item Continue to prompt for additional items, until the user enters 0 Display the total. Prompt for the dollar amount the customer submits as payment. Display the change due.

  • Write a program called problem4.cpp to implement an automatic teller machine (ATM) following the BankAccount class...

    Write a program called problem4.cpp to implement an automatic teller machine (ATM) following the BankAccount class the we implemented in class. Your main program should initialize a list of accounts with the following values and store them in an array Account 101 → balance = 100, interest = 10% Account 201 → balance = 50, interest = 20% Account 108 → balance = 200, interest = 11% Account 302 → balance = 10, interest = 5% Account 204 → balance...

  • MATLAB EXPERT PLS HELP!!! SHORT AND SIMPLE QUESTIONS! Just write the code to do the following...

    MATLAB EXPERT PLS HELP!!! SHORT AND SIMPLE QUESTIONS! Just write the code to do the following operations step by step please. You dont need background info on the question Prompt the user to enter x and if x is less than 2 or not an integer, use a while loop to display “Invalid!” and prompt the user to re-enter valid entries. Prompt the user to enter y as a vector of x elements. If the user did not enter in...

  • Using MATLAB program to solve the following question please: Write a script called echostring that will...

    Using MATLAB program to solve the following question please: Write a script called echostring that will prompt the user for a string, and will echo print the string in quotes (with an extra little surprise at the end): >> echostring Enter your string: I like nap Your string was: ‘I like nap – in MATLAB class’

  • Please post following code with criteria below... please leave as many comments as possible Exam Four:...

    Please post following code with criteria below... please leave as many comments as possible Exam Four: the election Outcome: Student will demonstrate all core competencies from this class: Program Design (design tools) Variables Decision Error Checking Looping Functions Arrays Program Specifications: Let’s pretend that we are tracking votes for the next presidential election. There will be two candidates: Ivanka Trump and Michele Obama. You can assume that there are fifty states casting votes. You will do not need to deal...

  • this is for java programming Please use comments Use the Account class created in homework 8_2...

    this is for java programming Please use comments Use the Account class created in homework 8_2 to simulate an ATM machine. Create ten checking accounts in an array with id 0, 1, …, 9, initial balance of $100, and annualInterestRate of 0. The system prompts the user to enter an id between 0 and 9, or 999 to exit the program. If the id is invalid (not an integer between 0 and 9), ask the user to enter a valid...

  • Need help please! Question 1: you must use if /else statement to receive credit for this...

    Need help please! Question 1: you must use if /else statement to receive credit for this question Write a MATLAB script to prompt the user to enter the value of t and use if /else statement to calculate f(t): 0. ift 0.5 f)2t2, if 0.5<t<1 4t. for all other t Test your code with different values of t. Question2: you must use switch/case to receive credit for this question Create a script to prompt the user to enter TWO numbers....

  • Please show the code necessary, and explanations on MATLAB. Plotting 11) Plot the function y =...

    Please show the code necessary, and explanations on MATLAB. Plotting 11) Plot the function y = sin(x) from x = 0 to 21. 12) Plot the functions y = x2 z = x2 + 2x + 1 from x = 0 to 2 on the same graph. Scripts: Input and Output 13) Write a script (M-file) to read in a message at the command line using the MATLAB input function and then display the message to the Command Window using...

  • 3,4,5,6,7,8 please 1. Enter the code to prompt a user to enter their name into a...

    3,4,5,6,7,8 please 1. Enter the code to prompt a user to enter their name into a script and save to name. imputl name) 2. Enter the code to display their name to the command window using "disp" function. 3. Enter the code to display their name using the "fprintf" function ame 4. What is the main difference between the "disp and "fprintf" commands? on 5. What is the main difference between the "fprintf" and "sprintf" commands? 6. What is a...

  • Calculate the Balance - Withdrawal If the action is Withdrawal ‘W’, use the withdrawal function to...

    Calculate the Balance - Withdrawal If the action is Withdrawal ‘W’, use the withdrawal function to remove funds from the account Hint – The formatter for a float value in Python is %f. With the formatter %.2f, you format the float to have 2 decimal places. For example: print("Account balance: $%.2f" % account_balance) Withdrawal Information Withdraw Input userchoice = input ("What would you like to do?\n") userchoice = 'W' withdrawal_amount = 100 Withdraw Output What would you like to do?...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT