14-440-127 Recitation 9 Problems

14-440-127 Recitation 9 Problems - 14:440:127- Introduction...

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

View Full Document Right Arrow Icon
14:440:127- Introduction to Computers for Engineers Problems for students to attempt in Recitation 9. I asked the TAs to propose problems approximately the difficulty they would expect from Exam 2 questions. 1) Write a function called “dice” that simulates the throw of two dice by returning a vector containing 2 random integers between 1 and 6. 2) Write a function that outputs the 9th prime number in a vector. The vector is 121:1:4343. You cannot use the primes( ) function, although you certainly may use the isprime( ) function. 3) Write down the basic structure of 'for' and 'while' loop. (You don't need specify variable names). What are the major differences between the two methods? 4) Use for loop and the following formula to calculate π /4: 5) Write Matlab code that performs the basic tasks of an ATM machine. The starting account balance is $500. Ask the user for a PIN, and accept any four digit number. Ask the user whether he/she would like to deposit funds, withdraw funds, or display the account balance (using the menu command). 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 (this allowing additional transactions) until the user chooses “Return Card.” At that point, use fprintf to display the final account balance. 6)
Background image of page 1

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

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

Page1 / 2

14-440-127 Recitation 9 Problems - 14:440:127- Introduction...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online