D- Computer Questions- SolutionsExam 2

D- Computer Questions- SolutionsExam 2 - Computer Question...

Info iconThis preview shows pages 1–2. 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 $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. c = { 'morning' 'afternoon' 'day' }; fprintf( 'Good %s\n' ,c{ceil(3*rand(1))}) total=0; count=0; while (1) wc = menu( 'Choose your food:' , 'Cheeseburger' , 'Chicken Rings' , 'Mozzarella Sticks' , 'Sweet Tea' , 'Let''s Eat'
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.

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

Page1 / 3

D- Computer Questions- SolutionsExam 2 - Computer Question...

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