F- Computer QuestionsExam 2

F- Computer QuestionsExam 2 - x(t)=t*sin(t) and...

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, leaving a trail behind it. Let t run from 0.1 to 50:
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: x(t)=t*sin(t) and y(t)=5log(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 while loop that computes the sum of the first 502 prime numbers. You cannot use the sum or primes functions in your solution. However, you may certainly use isprime . Computer Question 4: Write a function called biggestdifference that takes as input a matrix, and returns the value of the largest difference between any two adjacent elements (i.e. elements that are next to each other vertically or horizontally.) This is the last problem from Problem Set 2, except you dont need to specify the location of these elements; just return the value of the largest difference. Your solution must use a nested loop rather than matrix operations. In particular, you cannot use max , sort, or similar functions....
View Full Document

Ask a homework question - tutors are online