4B PROGRAMSExcellence (5 points): Complete ReallyMeanIt and BlackJack within 50 hours. All coding standards are demonstrated.
Advanced (4 points): Complete ReallyMeanIt and BlackJack by the end of Cycle 4. All coding standards are demonstrated. Proficient (3 points): Complete ReallyMeanIt by the end of Cycle 4. |
|
ReallyMeanIt
Write a program that reads in real numbers, and then prints the average of the numbers to two decimal places. The user must be able to determine when he/she has completed entering them by entering a sentinel value.
Take caution in making your sentinel value a number, because that number could potentially be a value entered as part of the average. For example, "Enter a number or press 0 to quit" will not work because 0 could potentially be the next number in the set for which you wish to take the average.
You may use any loop type you choose.
TEST DATA:
INPUTS:
User enters 3, chooses not to quit.
User enters 6, chooses not to quit.
User enters 12, chooses to quit
OUTPUT: Average: 7.00
INPUTS:
User enters 2, chooses to quit.
OUTPUT: Average: 2.00
INPUTS:
User enters 2, chooses not to quit.
User enters 1, chooses not to quit.
User enters 0, chooses not to quit
User enters -1, chooses not to quit.
User enters -3, chooses to quit.
OUTPUT: Average: -0.20
Write a program that reads in real numbers, and then prints the average of the numbers to two decimal places. The user must be able to determine when he/she has completed entering them by entering a sentinel value.
Take caution in making your sentinel value a number, because that number could potentially be a value entered as part of the average. For example, "Enter a number or press 0 to quit" will not work because 0 could potentially be the next number in the set for which you wish to take the average.
You may use any loop type you choose.
TEST DATA:
INPUTS:
User enters 3, chooses not to quit.
User enters 6, chooses not to quit.
User enters 12, chooses to quit
OUTPUT: Average: 7.00
INPUTS:
User enters 2, chooses to quit.
OUTPUT: Average: 2.00
INPUTS:
User enters 2, chooses not to quit.
User enters 1, chooses not to quit.
User enters 0, chooses not to quit
User enters -1, chooses not to quit.
User enters -3, chooses to quit.
OUTPUT: Average: -0.20
MovingTarget
This is a two player game that can be set up as human v human or human v computer. Make either version.
The game works like this:
--Get player names as Player 1 and Player 2 (or, if human v computer, just Player 1).
--A random number from 2-10 is generated. This will be the number of ROUNDS in the game. This number remains unknown to the users.
----Within a ROUND, you will play an unknown number of SETS.
------Within a SET, a random number from 1-100 is generated. This number is the TARGET.
------Both players guess the target number and their distance away from the target is calculated.
------The difference between the distances is awarded to the closer guesser (example. TARGET = 50, P1 GUESS = 20, P2 GUESS = 60. P1 is 30 away and P2 is 10 away. P2 is then awarded 20 points.
------The player who won that SET chooses to CONTINUE (by playing another SET) or END the round. If there was a tie, then P1/Human selects to continue.
----The total number of points earned in that ROUND go to each player's grand total.
----If there are more ROUNDS to be played (see the first point), play the next ROUND. If not, the game is over and the player with the most total points wins.
SAMPLE
Random Round Selection = 3
ROUND 1
SET 1
--Target 33, P1 guess 35, P2 guess 63. P1 awarded 28 points. P1 elects to play another set.
SET 2
--Target 58, P1 guess 10, P2 guess 78. P2 awarded 28 points. P2 elects to end round.
ROUND 2
SET 1
--Target 45, P1 guess 50, P2 guess 40. No one is awarded points. P1 elects to play another set.
SET 2
--Target 6, P1 guess 32, P2 guess 31. P2 awarded 1 point. P2 elects to end round.
ROUND 3
SET 1
--Target 28, P1 guess 9, P2 guess 77. P1 awarded 30 points. P1 elects to play another set.
SET 2
--Target 50, P1 guess 22, P2 guess 54. P2 awarded 24 points. P2 elects to play another set.
SET 3
--Target 17, P1 guess 7, P2 guess 12. P2 awarded 5 points. P2 elects to play another set.
SET 4
--Target 41, P1 guess 20, P2 guess 88. P1 awarded 16 points. P1 elects to end round.
GAME IS OVER
Final score: P1 74 points, P2 58 points. Player 1 is declared winner.
This is a two player game that can be set up as human v human or human v computer. Make either version.
The game works like this:
--Get player names as Player 1 and Player 2 (or, if human v computer, just Player 1).
--A random number from 2-10 is generated. This will be the number of ROUNDS in the game. This number remains unknown to the users.
----Within a ROUND, you will play an unknown number of SETS.
------Within a SET, a random number from 1-100 is generated. This number is the TARGET.
------Both players guess the target number and their distance away from the target is calculated.
------The difference between the distances is awarded to the closer guesser (example. TARGET = 50, P1 GUESS = 20, P2 GUESS = 60. P1 is 30 away and P2 is 10 away. P2 is then awarded 20 points.
------The player who won that SET chooses to CONTINUE (by playing another SET) or END the round. If there was a tie, then P1/Human selects to continue.
----The total number of points earned in that ROUND go to each player's grand total.
----If there are more ROUNDS to be played (see the first point), play the next ROUND. If not, the game is over and the player with the most total points wins.
SAMPLE
Random Round Selection = 3
ROUND 1
SET 1
--Target 33, P1 guess 35, P2 guess 63. P1 awarded 28 points. P1 elects to play another set.
SET 2
--Target 58, P1 guess 10, P2 guess 78. P2 awarded 28 points. P2 elects to end round.
ROUND 2
SET 1
--Target 45, P1 guess 50, P2 guess 40. No one is awarded points. P1 elects to play another set.
SET 2
--Target 6, P1 guess 32, P2 guess 31. P2 awarded 1 point. P2 elects to end round.
ROUND 3
SET 1
--Target 28, P1 guess 9, P2 guess 77. P1 awarded 30 points. P1 elects to play another set.
SET 2
--Target 50, P1 guess 22, P2 guess 54. P2 awarded 24 points. P2 elects to play another set.
SET 3
--Target 17, P1 guess 7, P2 guess 12. P2 awarded 5 points. P2 elects to play another set.
SET 4
--Target 41, P1 guess 20, P2 guess 88. P1 awarded 16 points. P1 elects to end round.
GAME IS OVER
Final score: P1 74 points, P2 58 points. Player 1 is declared winner.
BlackJack
This program is intended to be built off of ShuffleAndDeal, a program from Module 3A. If you wrote that program, you should have the core elements to get this one started.
In this program, you will simulate a single player versus dealer game of blackjack. I am interested in seeing your creative take on developing this, so I won't tell you exactly what needs to be done except to say that it must follow the rules below.
The objective of the game is to get a score of 21 or as close as possible so that the player has a superior score to the dealer. The score is determined by the sum of the card values, where face cards (J, Q, K) are 10 and aces can be 1 or 11.
Here are the rules:
This program is intended to be built off of ShuffleAndDeal, a program from Module 3A. If you wrote that program, you should have the core elements to get this one started.
In this program, you will simulate a single player versus dealer game of blackjack. I am interested in seeing your creative take on developing this, so I won't tell you exactly what needs to be done except to say that it must follow the rules below.
The objective of the game is to get a score of 21 or as close as possible so that the player has a superior score to the dealer. The score is determined by the sum of the card values, where face cards (J, Q, K) are 10 and aces can be 1 or 11.
Here are the rules:
- The player makes a wager of a number of chips, up to the number he/she currently has in possession. For this game, give the player 10 chips to start.
- The dealer deals two cards face up to the player and one card face up and one card face down to himself.
- If either the player or dealer has a "natural" twenty-one (Ace + Face/10) on the deal, the round is over with the "natural" hand being the winner.
- If the player and dealer both have a "natural" twenty-one on the deal, the round is over in a tie.
- The player can choose to "stand" or "hit". A "hit" means that the player will be dealt another card. The player can hit as many times as he/she wishes, but if his/her score goes over 21 then the round is over with the dealer winning. A "stand" means the player is done accepting cards and will take his her score.
- After the player chooses to "stand", the dealer's second card will be revealed and the scores of both players will be shown. Whoever has the higher score wins.
- If the dealer wins, the player loses all his/her chips. If the player wins, he gets 1.5 times his wager in chips, rounded down.
- The game ends when the player wishes to "quit" (at the end of a round) or if the player runs out of money.