Reference no: EM13334089
Pig - Dice Game
Gameplay
On a turn, a player rolls the die repeatedly until either:
A 1 is rolled
The player chooses to hold (stop rolling)
If a 1 is rolled, that player's turn ends and no points are earned.
If the player chooses to hold, all of the points rolled during that turn are added to his or her score.
Scoring Examples
Example 1:Sherri rolls a 3 and decides to continue. She then chooses to roll two more times (6, 1). Because she rolled a 1, Sherri's turn ends and she earns 0 points.
Game End
When a player reaches a total of 100 or more points, the game ends and that player is the winner.
However, we are going to create a modified version of this game where we are going to simulate 6 rolls in a row and determine if they have won or not.If any of those dice are 1, then the player loses. However, if none of the dice are 1, then it we should total the dice and print out their score.If they score over 20, then we are going to say they win.
·Note for all you purists out there, we will revisit this game when we have loops and if/else statements to make it more robust.
Below is the pseudocode to help start this process:
https://pastebin.com/xPj4AKcL
Program 2
Bacon Eater
The BaconEater class belowcontains a partial program that computes the cost of buying bacon at the store. Create the class and do the following:
1.Study the comments to determine what to do (look at the pastebin link below).
2.Add the import statements to import the DecimalFormat and NumberFormat classes.
3.Add the statement to declaremoneyto be a NumberFormat object as specified in the comment.
4.Add the statement to declarefmtto be a DecimalFormat object as specified in the comment.
5.Add the statements to print a label in the following format (the numbers in the example output are correct for input of138perpoundand324lbsUsetheformattingobjectmoneytoprinttheunitpriceandtotalpriceandtheformattingobjectfmttoprinttheweightto2decimalplaces
***** Bacon Eater *****
Sales Price:138perpound
Weight: 3.24 pounds
TOTAL:447
https://pastebin.com/9cFHYHua
** Enhance your program a bit so that you get the weight of 3 different bacon orders, calculate their sales price and the average sales price, weight, and cost per pound.
Program 3
Playing With Money
Write a program that creates an enumeration representing all the coins that we have in the US Currency.From there, you are going to ask the user for a dollar and cents amount.You are going to figure out the coins that make up the dollar amount entered.Then, you will multiply the coin by the ordinal value of the each number in the enumeration.
Sample Output might look like this:
How much money do you want to convert? 3.45
3 Dollar coins
0 Fifty Cents
1 Quarter
2 Dimes
1 Nickel
0 Pennies
The new value is: 1 + 4 + 3 + 15 = 23
The pseudocode is listed here:
https://pastebin.com/Av4wLfs8
Explain reaction spontaneous at standard conditions
: At what temperatures is this reaction spontaneous at standard conditions. Assume that ?H° and ?S° do not depend on temperature.
|
Find how many forces act on the crate
: A rocket, away from all gravitational forces, accelerates upward at an acceleration of 12.8m/s^2. On its main deck is a crate with a mass of 81.6kg. How many forces act on the crate
|
What will be the par value of the holdings in the 20-year
: If a firm remains in business indefinitely, the pension obligation will resemble a perpetuity. Suppose, therefore, that you are managing a pension fund with obligations to make perpetual payments of $3.0 million per year to beneficiaries.
|
What is an imaginary number
: Complex numbers are what you get when you add real and imaginary numbers. What is an imaginary number? How are they different or similar to real numbers? What applications do they have?
|
Write a program that creates an enumeration representing
: Sherri rolls a 3 and decides to continue. She then chooses to roll two more times (6, 1). Because she rolled a 1, Sherri's turn ends and she earns 0 points.
|
Average amount in the bottles is computed
: An automated filling process used by a soft drink manfacturer fills bottles marked as containing 32 ounces. The amount, X, in the bottles is assumed to be a normally distributed random variable. To monitor the process, a random sample of 25 bottles i..
|
What would be the expected return on a zero-beta stock
: Suppose the yield on short-term government securities (perceived to be risk-free) is about 7.76%. Suppose also that the expected return required by the market for a portfolio with a beta of 1.0 is 17.76%
|
What is the present value and duration of the obligation
: You will be paying $11,800 a year in tuition expenses at the end of the next two years. Bonds currently yield 9%. What is the present value and duration of your obligation
|
Find what is the percentage change in the bonds price
: A(n) seven-year bond has a yield of 8% and a duration of 7.199 years. If the bond's yield changes by 25 basis points, what is the percentage change in the bond's price
|