E- Computer QuestionsExam 2

E- Computer QuestionsExam 2 - screen Let x run from 0 to 25...

Info iconThis preview shows page 1. 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 a cashier at Taco Bell. First, display a menu asking the user what she’d like to eat: Taco $0.99 Burrito $1.99 Cinnamon Twists $0.79 Fruitista Freeze $2.09 Include a fifth menu option, “Let’s Eat”. Each time a user clicks on a menu item, add that cost to the total (which starts at $0.00), and then display the menu again. Once the user clicks on “Let’s Eat”, stop displaying the menu, but use fprintf to display the final total (to two decimal places), as well as the total number of items they ordered. In addition, randomly generate an “order number” for them (which should be an integer from 1 to 1000), and use fprintf to announce their order number i.e. “Your order number is 145.” Use switch rather than if statements in your answer. Computer Question 2: Write code that animates the following equation as an ‘O’ bouncing around the
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: screen. Let x run from 0 to 25: y = x*sin(15-x) Use appropriate axes, and make sure that the animation works when you run it. Computer Question 3: The coordinates of an object, as a function of time t , for 0<= t <= 4 are: x(t) = 5t-10 y(t) = 25t 2-120t + 144 Write a program that determines the time at which the object is closest to the origin. Recall that the distance from the origin is sqrt(x^2+y^2). You are not permitted to use the min function—instead, use a loop to calculate the minimum. Computer Question 4: Write a function called makeupnumber that returns a random integer from 3 to 30. Note that the function does not take any input. Now, write Matlab code that calls makeupnumber 1000 times and displays which integer was returned most often. If there are multiple maxes (i.e. multiple integers were returned the same number of times), the program should display all of those....
View Full Document

This note was uploaded on 02/29/2012 for the course 440 127 taught by Professor Blase during the Fall '09 term at Rutgers.

Ask a homework question - tutors are online