{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

G- Computer QuestionsExam 2

G- Computer QuestionsExam 2 - Computer Question 3 Write a...

Info iconThis preview shows page 1. 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. Computer Question 2: Write code that animates the following equation, leaving a trail behind it. Let t run from 0 to 50: x(t)=5cos(t) and y(t)=t*sin(t) Use appropriate axes, and make sure that the animation works when you run it. Here are two screen shots of the “middle” and the “end” of the animation:
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Computer Question 3: Write a program that generates a random integer in the range of 1 to 100 and asks the user to guess the number. You program should keep asking the user for guesses until it is correct. For each incorrect guess, you program should hint if the guess is larger or smaller than the random number you generated. Computer Question 4: Write a function called myISPRIME . Your function should take one input argument and mirror the functionality of the built-in isprime function—return 1 if the input number is prime, and 0 otherwise. Hint: a prime number is divisible only by 1 and itself. Loop through all of the numbers in between “1 and itself” and use the rem function to see if you find any numbers that divide the input evenly. You may not use primes, isprime , or similar functions as part of your solution....
View Full Document

  • Fall '09
  • blase
  • Prime number, Remote control, channel number, final menu item, TV remote control, built-in isprime function—return

{[ snackBarMessage ]}

Ask a homework question - tutors are online