1F PROGRAMSExcellence (6 points): Complete Lucky7, RegisterRoulette, and Yahtzee within 50 hours. All coding standards are demonstrated throughout all programs.
Advanced (5 points): Complete Lucky7, RegisterRoulette, and Yahtzee before the due date. All coding standards are demonstrated throughout all programs. Proficient (4 points): Complete Lucky7 and RegisterRoulette before the due date. All coding standards are demonstrated throughout all programs. Basic (3 points): Complete Lucky7 and submit a non-functioning RegisterRoulette before the due date. Below Basic (2 points): Complete Lucky7 before the due date. |
|
THIS MODULE'S ALBUMS: |
Lucky7
This program simulates the roll of two die (dice). Create two random values from 1 to 6 and store them in a variable. Use if-then statements to output some ASCII art to show the results of the "roll". Here is a template with which to form your images. Finally, if the sum of your two random numbers is 7, output the message "You are lucky!".
Test Data: Run this enough times to ensure three diffe
rent combos of 7 (like 2-5, 5-2, 6-1) gives the "You are lucky!" message, and enough times to be fairly sure no other sum gives the message.
This program simulates the roll of two die (dice). Create two random values from 1 to 6 and store them in a variable. Use if-then statements to output some ASCII art to show the results of the "roll". Here is a template with which to form your images. Finally, if the sum of your two random numbers is 7, output the message "You are lucky!".
Test Data: Run this enough times to ensure three diffe
rent combos of 7 (like 2-5, 5-2, 6-1) gives the "You are lucky!" message, and enough times to be fairly sure no other sum gives the message.
RegisterRoulette
Boscov’s has long used their “Register Roulette” promotion to try to increase sales. Shoppers bring their purchases to the register and a randomized computer program selects a discount from the following choices: 10%, 20%, 30%, 40%, or 50%.
Write a program that will ask the user to enter the name and advertised price of three different items. The computer will randomly generate a percentage from the above list and perform several calculations involving that discount (see below).
The program should:
Sample Test:
INPUTS
Jeans
25.00
Belt
15.00
Slippers
8.49
RANDOM PERCENTAGE = 10% (keep in mind that different random values will change this--you don't have that control)
OUTPUTS
You saved 10% today with Register Roulette!
Jeans: Original $25.00, Discounted $22.50
Belt: Original $15.00, Discounted $13.50
Slippers: Original $8.49, Discounted $7.64
Total Owed: $43.64
You saved $4.85 today with Register Roulette!
Boscov’s has long used their “Register Roulette” promotion to try to increase sales. Shoppers bring their purchases to the register and a randomized computer program selects a discount from the following choices: 10%, 20%, 30%, 40%, or 50%.
Write a program that will ask the user to enter the name and advertised price of three different items. The computer will randomly generate a percentage from the above list and perform several calculations involving that discount (see below).
The program should:
- Output a message telling the user what the percentage is.
- Output the name of each item, the original price of the item, and the discounted price of each item.
- Output the total amount the customer owes—which would be the sum of the discounted prices.
- Output a final message to the user telling them how much money they saved today (because of Register Roulette).
Sample Test:
INPUTS
Jeans
25.00
Belt
15.00
Slippers
8.49
RANDOM PERCENTAGE = 10% (keep in mind that different random values will change this--you don't have that control)
OUTPUTS
You saved 10% today with Register Roulette!
Jeans: Original $25.00, Discounted $22.50
Belt: Original $15.00, Discounted $13.50
Slippers: Original $8.49, Discounted $7.64
Total Owed: $43.64
You saved $4.85 today with Register Roulette!
Yahtzee
If you have never had the chance to play this game, give it a try here. The concept is simple: with three rolls of five dice, rolling ONLY the dice which you wish to change, achieve different scoring options such as "large straight", "fives only", and "full house".
A Yahtzee is achieved when ALL five dice are identical in three rolls or less. For this program, you MAY use the graphics developed in Lucky7 but I will only require you to show the numbers on each of the dice after each roll. This will save you some time if you are nearing the deadline.
Ω Display the letters A, B, C, D, and E next to the numbers/dice. Ask the user if he/she would like to keep or re-roll each of the dice, such as "Would you like to [K]eep or [R]e-roll A?". (Note: the square brackets serve as an indication to enter that letter as the choice--K for keep and R for re-roll.) Ultimately, your program should ONLY keep the die if K or k is entered--anything else will result in a re-roll.
Once the fate of all five dice are determined, conduct the second roll by re-randomizing the values on any dice that were not ordered to be kept. If the user chose to keep those dice, then they should remain unchanged. Output the results of the second roll. Ω
Repeat the process between the Ω above to enact the third roll. After the third roll is complete, conduct a check to see if a Yahtzee has been formed. Output the message "Yahtzee!!!" if there is indeed one. Otherwise, the program should conclude. Note: If the user would get a Yahtzee on the first or second roll, they would need to just select K/k for all dice until the third roll was completed. Later on in this course, you will learn how to zip past the existing turns.
Test Data: Play and play and play until you confirm that the Yahtzee function works.
If you have never had the chance to play this game, give it a try here. The concept is simple: with three rolls of five dice, rolling ONLY the dice which you wish to change, achieve different scoring options such as "large straight", "fives only", and "full house".
A Yahtzee is achieved when ALL five dice are identical in three rolls or less. For this program, you MAY use the graphics developed in Lucky7 but I will only require you to show the numbers on each of the dice after each roll. This will save you some time if you are nearing the deadline.
Ω Display the letters A, B, C, D, and E next to the numbers/dice. Ask the user if he/she would like to keep or re-roll each of the dice, such as "Would you like to [K]eep or [R]e-roll A?". (Note: the square brackets serve as an indication to enter that letter as the choice--K for keep and R for re-roll.) Ultimately, your program should ONLY keep the die if K or k is entered--anything else will result in a re-roll.
Once the fate of all five dice are determined, conduct the second roll by re-randomizing the values on any dice that were not ordered to be kept. If the user chose to keep those dice, then they should remain unchanged. Output the results of the second roll. Ω
Repeat the process between the Ω above to enact the third roll. After the third roll is complete, conduct a check to see if a Yahtzee has been formed. Output the message "Yahtzee!!!" if there is indeed one. Otherwise, the program should conclude. Note: If the user would get a Yahtzee on the first or second roll, they would need to just select K/k for all dice until the third roll was completed. Later on in this course, you will learn how to zip past the existing turns.
Test Data: Play and play and play until you confirm that the Yahtzee function works.
ABC: Pick3 (+2)
One of the games in the PA Lottery works like this: Purchase a 50-cent ticket and select three digits (repeats allowed), such as 9-3-4 or 3-2-2. If you guess that day's randomly chosen digits in order, win $250. If you guess that day's digits in the wrong order (this is known as a "box"), win $40.
Therefore, a player's guess of 8-3-8 would win $250 if the chosen digits were 8-3-8 or the player would win $40 if the chosen digits were 3-8-8 or 8-8-3.
Also, a guess of 2-3-6 would win $250 on 2-3-6 or $40 on 6-3-2, 3-2-6, 6-2-3, 3-6-2, or 2-6-3.
Write a program that selects three random digits, take in the user's three digit guess, asks the user how many tickets he/she wishes to purchase, and then outputs the correct numbers and the net change for the user to two decimal places.
Note: The net change would be the amount won, minus the amount spent.
Programmer Hint: Create your three random numbers prior to any writeln/readln with the user. However, during development, keep the three random numbers in {comments} and write three assignment statements so that the numbers are not random but of your choosing. This control allows you to ensure that your program works without the chaos created by randomization. The test data below will allow you to ensure success. Make sure to activate the random numbers before submitting your program.
Test Data (10 different tests shown here):
One of the games in the PA Lottery works like this: Purchase a 50-cent ticket and select three digits (repeats allowed), such as 9-3-4 or 3-2-2. If you guess that day's randomly chosen digits in order, win $250. If you guess that day's digits in the wrong order (this is known as a "box"), win $40.
Therefore, a player's guess of 8-3-8 would win $250 if the chosen digits were 8-3-8 or the player would win $40 if the chosen digits were 3-8-8 or 8-8-3.
Also, a guess of 2-3-6 would win $250 on 2-3-6 or $40 on 6-3-2, 3-2-6, 6-2-3, 3-6-2, or 2-6-3.
Write a program that selects three random digits, take in the user's three digit guess, asks the user how many tickets he/she wishes to purchase, and then outputs the correct numbers and the net change for the user to two decimal places.
Note: The net change would be the amount won, minus the amount spent.
Programmer Hint: Create your three random numbers prior to any writeln/readln with the user. However, during development, keep the three random numbers in {comments} and write three assignment statements so that the numbers are not random but of your choosing. This control allows you to ensure that your program works without the chaos created by randomization. The test data below will allow you to ensure success. Make sure to activate the random numbers before submitting your program.
Test Data (10 different tests shown here):