I did it! I completed the first 8 programming assignments! Here are some more I need to do, definitely tougher:
#1 Create the logic for an application that contains an array of 10 multiple-choice questions related to your favorite hobby. Each question contains three answer choices. Also create a parallel array that holds the correct answer to each question - A, B, or C. Display each question and verify that the user enters only A, B, or C as the answer - if not, keep prompting the user until a valid response is entered. If the user responds to a question correctly, display "Correct!" Otherwise, display "The correct answer is" and the letter of the correct answer. After the user answers all the questions, display the number of correct and incorrect answers.
#2 Create the logic for a dice game. The application randomly "throws" five dice for the computer and five for the player. As each random "throw" is made, store it in an array. The application displays all the values, which can be from 1 to 6 inclusive for each die. Decide the winner based on the following hierarchy of die values. Any higher combination beats a lower; for example, five of a kind beats four of a kind.
-Five of a kind
-Four of a kind
-Three of a kind
-A pair
Numeric dice values do not count, if both players have a three of a kind, it's a tie no matter what the values of the dice are. The game does not recognize a full house.
#3 Improve #2 so that dice value DO make a difference. A pair of 5s beats a pair of 4s.
#4 Hangman - User guesses letters in a hidden word. Store letters of the word in array. Display a dash for each missing letter. Allow user to continuously guess until all letters in the word are guessed. As the user guesses correct letters, display the word with the filled in letter. For example if the word is computer --------, and the user guesses 'p', show the word again as ---p----. Also, make sure that when a user guesses a letter, ALL the matching letters are filled in. For example, if the word is banana and the user guesses 'a', make sure all As are filled in.
#5 Create two parallel arrays that represent a standard deck of 52 playing cards. One array is numeric and holds the values 1 through 13 (representing ace, 1, 2, etc.) The other array is a string and holds suits. Create the arrays so that all 52 card/suit combos are represented. Create a War card game that randomly selects two card (one for player, one for computer) and declares a winner (or tie) based on the numeric value of the two cards. The game should play for 26 rounds, dealing a whole deck with no repeated cards. For this game, assume the cards' values are based on their numbers. Display the value of the player's and computer's cards, compare their values, and determine the winner. When all cards in the deck are exhausted, display a count of the number of times the player wins, the number of times the computer wins, and the number of ties.
Hints:
-Start by creating an array of all 52 playing cards.
-Select a random number for the deck position of the player's first card and assign the card at
that array position to the player.
-Move every higher-positioned card in the deck "down" one to fill in the gap. In other words, if
the player's first random number is 49, select the card at position 49 (both the numeric value
and the string), move the card that was in position 50 to position 49, and move the card that
was in position 51 to position 50. Only 51 cards remain in the deck after the player's first
card is dealt, so the available-card array is smaller by one.
#6 Create a guessing game called "Does It Have Legs?" in which you think of an animal and the computer tries to guess what it is. The game continually becomes "smarter" as you play because you teach it how to become more specific with its questions. For example, a typical game session might proceed as follows:
Computer: Does the animal you are thinking of have legs?
Player: Yes.
Computer: Yay! I win. Do you want to play again?
Player: Yes
Computer: Does the animal you are thinking of have legs?
Player: Yes
Computer: Is it a dog?
Player: No.
Computer: I give up. What was your animal?
Player: horse.
Computer: Type a question for which the answer is Yes for dog and No for horse.
Player: Does it live in the house?
Computer: Do you want to play again?
Player: Yes
Computer: Does the animal you are thinking of have legs?
Player: Yes
Computer: Does it live in the house?
Player: No
Computer: Is it a horse?
Player: No.
Computer: I give up. What was your animal?
Player: cow.
Computer: Type a question for which the answer is Yes for horse but No for cow.
Player: Do people ride it?
Computer: Do you want to play again?
Player: Yes
Computer: Does the animal you are thinking of have legs?
Player: Yes
Computer: Does it live in the house?
Player: No
Computer: Do people ride it?
Player: No
Computer: Is it a cow?
Player: Yes
Computer: Yay! I win. Do you want to play again?
Player: No
Hint: Look up binary trees to organize this.
#7 Improve #4 to hold an array of 10 words. One at a time, pass each to a method that allows the user to continuously guess a letter until all the letters in the word are correctly guessed. The method returns the number of guesses it took to complete the word. Store the number in an array before returning to the method for the next word. After all 10 words have been guesses, display a summary of the number of guesses it took for each word as well as the average number of guesses per word.
Tuesday, November 30, 2010
Subscribe to:
Post Comments (Atom)

0 comments:
Post a Comment