Question
using simple and basic C++

2. In a game called lucky 6, for each game, a biased die is tossed repeatedly, and a payoff of 2 dollars is made, where n i
0 0
Add a comment Improve this question Transcribed image text
Answer #1

1 #include <iostream> #include <time.h 2 3 #include <cmath> using namespace std int rollDice ( 6 7 rand % 8 1; int num = == 4

while(games <= 100) 21 22 rollDice) ) ; 23 int dice = 24 cout < games << 25 cout << dice << 26 int count 1; while(dice

#include <iostream>

#include <time.h>

#include <cmath>

using namespace std;

int rollDice()

{

int num = rand() % 8 + 1;

if(num == 4 || num == 7)

return 4;

if(num == 5 || num == 8)

return 8;

return num;

}

int main() {

srand(time(NULL));

long long int payoff = 0;

int games = 1;

while(games <= 100)

{

int dice = rollDice();

cout << games << ") ";

cout << dice << " ";

int count = 1;

while(dice != 6)

{

dice = rollDice();

count++;

cout << dice << " ";

}

if(count <= 9)

cout << "Payoff = $0" << endl;

else

{

cout << "Payoff = $" << pow(2,count) << endl;

payoff += pow(2, count);

}

games++;

}

cout << "Average payoff = " << payoff / 100;

}

/*Sample Output

1) 4 8 1 4 1 8 2 6 Payoff = $0

2) 3 8 3 8 3 1 1 2 8 8 3 4 8 1 4 8 3 6 Payoff = $262144

3) 4 8 3 1 4 6 Payoff = $0

4) 8 8 2 6 Payoff = $0

5) 4 3 3 6 Payoff = $0

6) 4 8 2 1 8 3 2 8 4 8 3 3 8 6 Payoff = $16384

7) 3 4 3 6 Payoff = $0

8) 3 8 4 4 3 3 3 4 8 6 Payoff = $1024

9) 6 Payoff = $0

10) 2 3 4 4 4 4 3 6 Payoff = $0

11) 6 Payoff = $0

12) 4 4 2 1 4 6 Payoff = $0

13) 6 Payoff = $0

14) 1 4 8 6 Payoff = $0

15) 6 Payoff = $0

16) 8 4 4 4 4 6 Payoff = $0

17) 2 6 Payoff = $0

18) 3 4 8 8 2 6 Payoff = $0

19) 1 8 8 6 Payoff = $0

20) 2 4 2 3 4 8 8 8 8 3 4 8 1 8 1 4 6 Payoff = $131072

21) 4 2 4 4 4 8 3 1 6 Payoff = $0

22) 8 1 3 8 6 Payoff = $0

23) 4 6 Payoff = $0

24) 4 4 4 6 Payoff = $0

25) 6 Payoff = $0

26) 8 8 1 4 2 1 3 2 4 1 8 8 4 3 1 4 6 Payoff = $131072

27) 1 1 8 1 3 4 6 Payoff = $0

28) 4 1 8 8 8 2 2 4 4 2 4 8 2 2 1 6 Payoff = $65536

29) 2 8 2 8 2 2 3 4 2 4 4 2 6 Payoff = $8192

30) 4 8 4 8 4 8 4 8 2 4 3 3 6 Payoff = $8192

31) 2 8 4 2 2 8 1 3 4 3 8 2 1 6 Payoff = $16384

32) 8 4 8 2 3 4 6 Payoff = $0

33) 2 2 8 8 6 Payoff = $0

34) 6 Payoff = $0

35) 3 1 1 8 2 8 6 Payoff = $0

36) 4 6 Payoff = $0

37) 8 4 8 4 6 Payoff = $0

38) 4 8 4 2 1 2 1 2 4 4 4 8 8 4 1 8 1 4 8 1 3 4 8 1 2 2 8 8 2 8 3 8 4 1 6 Payoff = $3.43597e+10

39) 4 2 6 Payoff = $0

40) 6 Payoff = $0

41) 6 Payoff = $0

42) 4 4 2 3 4 3 8 8 6 Payoff = $0

43) 4 8 8 2 8 8 3 6 Payoff = $0

44) 8 8 4 4 2 4 8 2 1 3 3 4 8 8 2 4 2 8 2 4 4 1 1 4 1 8 1 8 8 3 2 4 2 1 4 3 46 Payoff = $2.74878e+11

45) 4 4 1 4 2 8 6 Payoff = $0

46) 4 3 4 8 8 2 3 8 2 1 8 2 1 1 1 4 3 4 8 3 2 8 6 Payoff = $8.38861e+06

47) 8 3 1 8 1 3 4 4 6 Payoff = $0

48) 2 8 8 6 Payoff = $0

49) 4 4 2 8 4 4 1 8 4 1 3 1 4 4 3 6 Payoff = $65536

50) 6 Payoff = $0

51) 8 8 1 1 4 1 3 2 4 8 3 4 4 8 2 2 2 1 8 8 2 4 6 Payoff = $8.38861e+06

52) 2 1 4 6 Payoff = $0

53) 8 1 3 8 1 4 8 1 2 6 Payoff = $1024

54) 3 3 4 2 6 Payoff = $0

55) 4 8 8 8 6 Payoff = $0

56) 6 Payoff = $0

57) 1 8 8 2 4 3 3 4 1 8 3 1 2 8 1 8 4 1 1 1 3 4 8 4 1 3 8 8 3 8 3 3 2 4 4 8 16 Payoff = $2.74878e+11

58) 8 1 6 Payoff = $0

59) 3 2 4 2 2 4 8 3 4 6 Payoff = $1024

60) 8 2 2 1 2 4 8 4 6 Payoff = $0

61) 8 1 8 6 Payoff = $0

62) 4 3 2 8 1 1 8 6 Payoff = $0

63) 3 1 4 4 3 2 1 8 1 6 Payoff = $1024

64) 1 2 4 1 4 2 1 2 8 8 2 4 2 8 2 3 4 2 3 4 4 6 Payoff = $4.1943e+06

65) 4 2 1 1 4 1 8 4 6 Payoff = $0

66) 6 Payoff = $0

67) 8 4 6 Payoff = $0

68) 8 6 Payoff = $0

69) 6 Payoff = $0

70) 1 8 2 2 3 3 2 4 8 8 8 8 6 Payoff = $8192

71) 3 8 8 8 8 8 8 6 Payoff = $0

72) 2 3 3 4 4 4 4 4 4 2 4 8 3 1 2 6 Payoff = $65536

73) 2 6 Payoff = $0

74) 2 1 2 1 4 8 8 3 1 2 4 8 4 8 2 1 6 Payoff = $131072

75) 8 4 2 6 Payoff = $0

76) 2 3 8 1 8 8 3 2 6 Payoff = $0

77) 8 4 6 Payoff = $0

78) 1 4 4 8 1 6 Payoff = $0

79) 8 2 8 4 8 4 8 8 2 8 4 3 2 8 8 6 Payoff = $65536

80) 1 1 2 3 3 4 2 6 Payoff = $0

81) 8 2 1 8 4 1 6 Payoff = $0

82) 3 2 2 4 1 8 3 1 6 Payoff = $0

83) 4 4 8 1 6 Payoff = $0

84) 4 6 Payoff = $0

85) 6 Payoff = $0

86) 8 8 8 4 6 Payoff = $0

87) 1 4 2 3 4 2 1 8 4 3 6 Payoff = $2048

88) 8 1 4 4 4 4 2 2 8 1 2 2 8 8 8 1 4 4 4 4 8 2 6 Payoff = $8.38861e+06

89) 2 8 4 2 1 8 4 4 4 8 8 4 8 3 8 1 4 1 3 8 8 2 4 8 8 6 Payoff = $6.71089e+07

90) 3 3 8 4 8 6 Payoff = $0

91) 8 6 Payoff = $0

92) 4 1 2 2 4 8 6 Payoff = $0

93) 3 4 8 8 3 6 Payoff = $0

94) 3 3 8 2 4 1 1 3 8 6 Payoff = $1024

95) 8 2 2 8 2 4 8 4 8 8 1 6 Payoff = $4096

96) 6 Payoff = $0

97) 8 4 8 8 8 4 3 8 6 Payoff = $0

98) 8 4 4 4 4 4 6 Payoff = $0

99) 3 4 3 8 8 2 6 Payoff = $0

100) 3 1 4 4 8 4 8 8 1 8 4 8 4 4 2 4 4 4 4 3 2 3 1 4 8 8 1 1 1 3 6 Payoff = $2.14748e+09

Average payoff = 5863604910

*/

Add a comment
Know the answer?
Add Answer to:
using simple and basic C++ 2. In a game called "lucky 6", for each game, a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Which is a better (or payoff) game for any player in the casino? Assume that each side with a dot; two dots; three dots,., and etc. (a) Toss a die (6-sided) once (b) Toss a die (4-sided) twice (c) Pl...

    Which is a better (or payoff) game for any player in the casino? Assume that each side with a dot; two dots; three dots,., and etc. (a) Toss a die (6-sided) once (b) Toss a die (4-sided) twice (c) Please show details of the work on each game and conclude. Which is a better (or payoff) game for any player in the casino? Assume that each side with a dot; two dots; three dots,... and etc. (a) Toss a die...

  • Please help me write these in R script / Code 1, Suppose you're on a game...

    Please help me write these in R script / Code 1, Suppose you're on a game show, and you're given the choice of three doors. Behind one door is a car; behind the others, goats. You pick a door, say #1, and the host, who knows what's behind the doors, opens another door, say #3, which has a goat. He then says to you, "Do you want to pick door #2?" What is the probability of winning the car if...

  • using basic c++ and use no functions from c string library b) Write a fragment of...

    using basic c++ and use no functions from c string library b) Write a fragment of code (with declarations) that reads a pair of words from the keyboard and determines how many letters in corresponding positions of each word are the same. The words consist only of the letters of the English alphabet (uppercase and lowercase). For example, if the words are coat and CATTLE, the following output should be generated: 012245 0122 matching letter in position 0 t is...

  • The Rules of Pig Pig is a folk jeopardy dice game with simple rules: Two players...

    The Rules of Pig Pig is a folk jeopardy dice game with simple rules: Two players race to reach 100 points. Each turn, a player repeatedly rolls a die until either a 1 (”pig”) is rolled or the player holds and scores the sum of the rolls (i.e. the turn total). At any time during a player’s turn, the player is faced with two decisions: roll If the player rolls a 1: the player scores nothing and it becomes the...

  • Exercise 6 (Difficult),. Consider the following modification of the prisoner's dilemma game. A-1,...

    Exercise 6 (Difficult),. Consider the following modification of the prisoner's dilemma game. A-1,-1-9,0-6,-2 B | 0,-9 |-6-61-5-10 C1-2,-6 |-10,-51-4,-4 You should recognise the payoff's from (A, L), (A, R). (B, L). (B, R) as those in the prisoner's dilemma game studied in class. We added two strategies, one for each player. Also note that strategies A and L are still (when compared to the original prisoner's dilemma game) strictly dominated . What is the set of Nash equilibria of this...

  • Assignment 2 – The two player game of Poaka The game of Poaka is a dice...

    Assignment 2 – The two player game of Poaka The game of Poaka is a dice game played by two players. Each player takes turns at rolling the dice. At each turn, the player repeatedly rolls a dice until either the player rolls a 1 (in which case the player scores 0 for their turn) or the player chooses to end their turn (in which case the player scores the total of all their dice rolls). At any time during...

  • 6. The following stage game is played repeatedly for 2 periods. Note that both players observe...

    6. The following stage game is played repeatedly for 2 periods. Note that both players observe the decisions made in period 1 before they play again in period 2. The final payoffs to each player are the sum of the payoffs obtained in each period. 112 L R T 1,1 5,0 B 0,3 7,7 (a) Represent this game in extensive form (tree diagram. How many subgames are there? (b) Using backward induction, find all subgame perfect Nash equilibria (SPE) in...

  • For this assignment, your job is to create a simple game called Opoly. The objectives of...

    For this assignment, your job is to create a simple game called Opoly. The objectives of this assignment are to: Break down a problem into smaller, easier problems. Write Java methods that call upon other methods to accomplish tasks. Use a seed value to generate random a sequence of random numbers. Learn the coding practice of writing methods that perform a specific task. Opoly works this way: The board is a circular track of variable length (the user determines the...

  • Please i need helpe with this JAVA code. Write a Java program simulates the dice game...

    Please i need helpe with this JAVA code. Write a Java program simulates the dice game called GAMECrap. For this project, assume that the game is being played between two players, and that the rules are as follows: Problem Statement One of the players goes first. That player announces the size of the bet, and rolls the dice. If the player rolls a 7 or 11, it is called a natural. The player who rolled the dice wins. 2, 3...

  • In the game of Pick-A-Ball, there are 10 colored balls: 3 red, 4 white, and 3...

    In the game of Pick-A-Ball, there are 10 colored balls: 3 red, 4 white, and 3 blue. The bals have been placed into a small bucket and the bucket has been shaken thoroughly You will be asked to reach into the bucket without looking and select 2 balls Secaus the bucket has been shaken thoroughly, you can assume that eadh individual ball is selected at random with equal likelhood of being chosen It is corsmon in games of chance to...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT