E- Computer Questions- SolutionsExam 2

E Computer - Computer Question 1 W rite Matlab code that performs the basic tasks of a cashier at Taco Bell First display a menu asking the user

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 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. total=0; items=0; while (1) tb = menu( 'Choose your food:' , 'Taco' , 'Burrito' , 'Cinnamon Twists' , 'Fruitista Freeze' , 'Let''s Eat' ); switch tb case 1 total=total+0.99; case 2 total=total+1.99; case 3 total=total+0.79; case 4 total=total+2.09; case 5 break end items = items+1;
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

E Computer - Computer Question 1 W rite Matlab code that performs the basic tasks of a cashier at Taco Bell First display a menu asking the user

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