D- Computer QuestionsExam 2

# D- Computer QuestionsExam 2 - Write code that animates the...

This preview shows page 1. Sign up to view the full content.

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 \$2.99 Mozzarella Sticks \$3.09 Sweet Tea \$2.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), as well as the total number of items they ordered. Use switch rather than if statements in your answer. Computer Question 2:
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Write code that animates the following equation, leaving a trail behind it. Let t run from 0.1 to 50: x(t)=5log(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: Computer Question 3: Write a loop to create the following matrix: 4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96 100 104 108 112 116 120 124 128 132 136 140 144 148 152 156 160 164 168 172 176 180 184 188 192 196 200 204 208 212 216 220 224 Computer Question 4: Recall that the Fibonacci sequence is defined as, Write a loop that calculates the sum of the first 9 prime Fibonacci numbers . (i.e. You may not use the sum or primes functions. However, you may certainly use isprime ....
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online