Recitation 10 Problems- Solutions

Recitation 10 Problems- Solutions - 14:440:127 Introduction...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
14:440:127 Introduction to Computers for Engineers Recitation 10- Solutions 1. Write a switch/case statement that displays the following menu for Taco Bell, allows the user to select one item, and then displays the amount of that item: Soft Taco $0.69 Chicken Soft Taco $1.99 Nachos Supreme $2.09 Fruitista Freeze $1.50 f = menu( 'May I take yr order?' , 'Soft Taco' , 'Chicken Soft Taco' , 'Nachos Supreme' , 'Fruitista Freeze' ); switch f case 1 disp( '$0.69' ) case 2 disp( '$1.99' ) case 3 disp( '$2.09' ) case 4 disp( '$1.50' ) end 2. Edit the menu above to include a fifth option: “done.” Each time the user selects an option, the menu should display again until the user chooses “done.” Then, display a list of what they ordered (and quantities), as well as the total amount of their purchase. Hint: use a while(1) loop, which is an infinite loop, and then have case 5 of your switch statement be a “break” statement. z = zeros(1,4); s = { 'Soft Taco' , 'Chicken Soft Taco' , 'Nachos Supreme' , 'Fruitista Freeze' }; while (1) f = menu( 'May I take yr order?' , s{1}, s{2}, s{3}, s{4}, 'Done' ); switch f case 1 z(1) = z(1)+1; case 2 z(2) = z(2)+1; case 3 z(3) = z(3)+1; case 4 z(4) = z(4)+1; case 5 break ; end end for a = 1:4 fprintf( '%s:\t%.0f\n' ,s{a},z(a)); end fprintf( '---\nTotal: $%.2f\n' ,sum(z.*[.69 1.99 2.09 1.50]));
Background image of page 1

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

View Full DocumentRight Arrow Icon
3. Write a GUI that has two editable text boxes and a button that says “Exponentiate”. When the
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/11/2010 for the course 440 127 taught by Professor Blase during the Fall '09 term at Rutgers.

Page1 / 5

Recitation 10 Problems- Solutions - 14:440:127 Introduction...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online