Answered step by step
Verified Expert Solution
Question
1 Approved Answer
coS 160 Program 4 - Meier Objectives Using random numbers and if/else statements. The Meier dice game Meier is a dice game where players take
coS 160 Program 4 - Meier Objectives Using random numbers and if/else statements. The Meier dice game Meier is a dice game where players take turns rolling a pair of dice hidden under a cup. The first player shakes the cup, inverts it on the table, and peaks at the dice. They announce what the dice are (usually honestly) and slide the inverted cup on to the next player The next player has several options, one of which it to reroll the dice. In this case they are required to anounce an equal or better roll than the previous one. If their roll was actually worse, then they have to bluff. At each step players can accept the previous roll unseen, or challenge it. If a player gets caught lying, they lose, but if an honset roll is challenged, then the challenger losses. When anouncing a roll, the higher die is always mentioned first. Like a poker hand, higher is better, and doubles (a matching pair) is higher than any unmatched dice, except that the very best roll is 2-1 and is called Meier. The complete rankings from lowest to highest are: 32 41, 42, 43 51, 52, 53, 54 61, 62, 63, 64, 65 11, 22, 33, 44, 55, 66 21 Oeier) This description is adequate for this assignment. You can find a more complete description of Meier's rules at: http://abitdicey.blogspot.com/2013/04/meier.html Part 1 (5 points) First player: Rolling 2 random dice Write code using Random to simulating rolling two random dice. You should get two random values from 1 to 6 and store them in variables die1 and die2. Print those variables like this: First player's roll is 2 4 Since it is using Random, it should get different results every time you run it. Run your program several times to make sure you can get all values from 1 to 6. Part 2 (5 points) Swaping so first die is the higher value Use an if statment to compare the two dice, and, if necessary, swap the values in die1 and die2. Note: to swap 2 values you will need a third temporary variable to hold one of the values and 3 assignment statements (like: temp = a; a-bi b-temp;). Move your printing e to the end of the program and again test it several times. It should now look like this: First player's roll is 4 2
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started