Thursday, October 28, 2010

Little Schedule of Programming

So I'm getting some assignments out of this book I had to use for a class. There is a section at the end of each chapter that asks students to describe how the logic of a particular program would work. Instead of describing the logic, however, I am just going to write the program. So here's what I have on the docket in order from easy to hard:

#1 Create a madlib.
#2 Create a program that generates a random number (1-10) and then asks the user to
     guess the number. Then display the random number so the user can see whether he/she
     is correct.
#3 Modify game 2 so that a message is displayed telling the user whether or not their number
     was too high or too low.
#4 Generate 3 random numbers (0-9,) ask the user to guess three numbers. Compare each
     guess to the three random numbers. Display a message that includes the user's guess, the
     three random numbers, and the amount of money the user has won as follows:
          No matches: $0
          One match: $10
          Two matches: $100
          Three matching, not in order: $1000
          Three matching, in order: $1,000,000
     (See page 192 for repeating digit info.)
#5 Modify game 2,3 so the user can continue to guess the correct number, display the number
     of times it took the user to guess the correct number.
#6 Create a five question quiz about something. Multiple choice questions with four options each.
     When the user gets an answer correct, display a congratulatory message. If the user was
     wrong display the respective message and ask the question again until the user correctly
     answers it.
#7 Create a game simulating two dice rolls and generates two numbers (1-6.) The user chooses a
     number between 2 (the lowest possible roll) and 12 (the highest possible roll.) The user then
     "rolls" the dice three times. If the number the user has pre-chosen is rolled, the user wins. If
     not, the computer wins.
#8 Create a dice game where the user and computer compete to first score 100 points. On a turn,
     the player rolls two dice. Rules:
          a.) If NONE of the dice on a roll have a number one on them, the dice values are added to a
               running total. The player can choose to roll again or to end their turn.
          b.) If there is a 1 on only ONE of the dice, nothing is added to the player's total and their
               turn ends.
          c.) If a 1 appears on BOTH the dice, the player's turn is over AND their score is reset to zero.
          d.) To simulate whether the computer chooses to end their turn or roll again (a,) generate a
               random value (1-2.) If the value is 1, the computer "decides" to end its turn. If the value
               is 2, the computer rolls again.

These will keep me busy for a while and comprise about a third of the book. When I complete these activities, I will post more.

0 comments:

Copyright © Shy Girl Speaks