G- Computer Questions- SolutionsExam 2

G- 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 code that simulates a TV remote control. Use the menu command to display the numbers 3 through 9 as separate buttons. (Note that they don’t have to be in the same layout as on a remote control). Have a final menu item: “Turn TV off” The user will click a channel number (3 through 9). Then, keep repeating this process of displaying the menu and clicking a channel number until “Turn TV off” is clicked. At that point, use fprintf to display 1) the last channel the TV was on before it was shut off, and 2) How many times the channel was changed. changed=0; while (1) tv = menu( 'Choose Channel: ' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , 'Turn TV Off' ); switch tv case 8 break ; otherwise channel=tv+2; changed=changed+1; end end fprintf( 'The final channel was %.0f, and it was changed %.0f times.\n' ,channel,changed); -0 if they are off by one with the number of times channel was changed, it’s ambiguous what that means -0 if they don’t use switch, they don’t have to -3 if they mess up fprintf, or have a small syntax error or two -3 if they mess up the “number of times channel changed” part
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.

Page1 / 3

G- 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