CS100 - Assignment 5 (Algorithms)

(Section 001, Fall 2007)

Write pseudocode/English to solve the following problems.

  1. (1 points) In a dice game where you throw two dice, you win if the sum of the two dice is 7 or 11, no one wins if you roll two identical dice, otherwise you lose. Given the two values rolled on the dice, output the correct message "You Win" or "No One Wins" or "You Lose".

  2. (2 points) A player is to guess a number between 1 and 100 chosen by the computer. The game continues as long as the number of guesses does not exceed MAXGUESSES and the player has not guessed the correct number.

  3. (2 points) For a given list of "n" integers, find how many integers are greater than the average of the list.

  4. (2 points) Given a positive integer "n" input by the user, find all the factors of "n".

  5. (3 points) Consider the following sequence of numbers: 1, 2, 3, 5, 8, 13, 21, 34, ... As you can see the third number is the first and second numbers added together. The fourth number is the second and third numbers added together. Or, in general, the current number is the previous number plus the number two previous added together. This sequence is called the Fibonacci sequence. Write a program that asks the user for how many numbers in the sequence they want to see and then outputs that many numbers of the sequence.



Gady Agam 2007-10-01