C- Computer QuestionsExam 2

C- Computer QuestionsExam 2 - Computer Question 1 W rite...

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 White Castle. First, use fprintf to randomly display either “Good morning”, “Good afternoon”, or “Good day”, each with equal probability. Now, display a menu asking the user what she’d like to eat: Cheeseburger $0.69 Chicken Rings $1.99 Mozzarella Sticks $2.09 Sweet Tea $1.50 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). Use switch/case rather than if statements in your answer. Computer Question 2: Write code that animates the following equation, leaving a trail behind it. Let t run from 0 to 50: x(t)=5cos(t) and y(t)=t*sin(t) Use appropriate axes, and make sure that the animation works when you run it. Here are two screen shots of the “middle” and the “end” of the animation:
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Ask a homework question - tutors are online