{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

E- Computer Questions- SolutionsExam 2

# E- Computer Questions- SolutionsExam 2 - Computer Question...

This preview shows pages 1–2. Sign up to view the full content.

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; end fprintf( 'The final total is %.2f for %.0f items\n'

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}