{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

B- Computer Questions- SolutionsExam 2

B- Computer Questions- SolutionsExam 2 - Computer Question...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Computer Question 1: Write Matlab code that performs the basic tasks of an ATM machine. The starting account balance is $1,000. Ask the user to enter a PIN, and accept any four digit integer. If they don’t enter a four digit integer as the PIN, your program should display “Incorrect PIN” and can stop right there. Now, display a menu asking the user whether he/she would like to deposit funds, withdraw funds, or display the account balance. Include a fourth menu item, “Return Card.” * If the user is depositing, ask how much to deposit and add it to the account balance. * If the user is withdrawing, allow withdrawing if there is enough money in the account and subtract it from the account balance. If there are insufficient funds, do not allow withdrawal and display an error message. Keep displaying the menu after each transaction (thus allowing additional transactions) until the user chooses “Return Card.” At that point, use fprintf to display the final account balance. balance=1000; pin = input( 'Enter the PIN Number' ); if (pin>=0 & pin<=9999 & round(pin)==pin) % Also OK: if(pin>=1000 & pin<=9999 & round(pin)==pin) while (1) choice = menu( 'Choose action:' , 'Deposit Funds' , 'Withdraw Funds' , 'Check Account Balance' , 'Return Card' ); switch choice case 1 d = input( 'How much do you want to deposit?' ); if (d>0) % optional. Don't take off if they don't do this check balance=balance+d; end case 2 w = input( 'How much do you want to withdraw?'
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern