Question

using basic c++

3. A certain 8-sided die is weighted such that 7s and 8s come up half as likely and 2s and 4s come up twice as often as a

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream> 1 #include <time.h> 2 using namespace std 4 int main) srand(time (NULL)); int dice[1000] 6 {0, е, е, е, в

#include <iostream>

#include <time.h>

using namespace std;

int main() {

srand(time(NULL));

int dice[1000] = {0, 0, 0, 0, 0, 0, 0, 0};

for(int i=0; i<500; i++)

{

int one = rand() % 18;

if(one == 0 || one == 1)

dice[0]++;

else if(one == 2 || one == 3)

dice[4]++;

else if(one == 4 || one == 5 || one == 6 || one == 7)

dice[1]++;

else if(one == 8 || one == 9)

dice[2]++;

else if(one == 10 || one == 11 || one == 12 || one == 13)

dice[3]++;

else if(one == 14 || one == 15)

dice[5]++;

else if(one == 16)

dice[6]++;

else if(one == 17)

dice[7]++;

}

for(int i=0; i<8; i++)

cout << i+1 << " occurred " << dice[i] << " times." << endl;

}

/*OUTPUT

1 occurred 60 times.

2 occurred 99 times.

3 occurred 55 times.

4 occurred 109 times.

5 occurred 55 times.

6 occurred 58 times.

7 occurred 30 times.

8 occurred 34 times.

*/

// Hit the thumbs up if you are fine with the answer. Happy Learning!

Add a comment
Know the answer?
Add Answer to:
using basic c++ 3. A certain 8-sided die is weighted such that 7's and 8's come...
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
  • 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...

  • using simple and basic C++ 2. In a game called "lucky 6", for each game, a...

    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 is the number of the toss on which the first "6" appears. The die is biased such that obtaining a "4" or "5" is twice more likely of showing up on a toss than the other numbers. Some examples follow. TOSS SEQUENCE 1 6 PAYOFF 22 $4 24 $16...

  • i. Consider a weighted 6-sided die that is twice as likely to produce any even outcome...

    i. Consider a weighted 6-sided die that is twice as likely to produce any even outcome as any odd outcome. What is the expected value of 1 roll of this die? What is the expected value of the sum of 9 rolls of this die? ii. Let X denote the value of the sum of 10 rolls of an unweighted 6-sided die. What is Pr(X = 0 mod 6)? (Hint: it is sufficient to consider just the last roll) *side...

  • 7. (3 points) Given a fair 6-sided die. Each time the die is rolled, the probabilities...

    7. (3 points) Given a fair 6-sided die. Each time the die is rolled, the probabilities of rolling any of the numbers from 1 to 6 are all equal. 1) If it is rolled once and let A be the event of rolling a number larger than 3 and B be the event of rolling an odd number. What is P(AV B)? 2) If it is rolled three times, what is the probability that the same number shows up in...

  • Consider rolling a fair 8 sided die. The sample space is S = {1, 2, 3,...

    Consider rolling a fair 8 sided die. The sample space is S = {1, 2, 3, 4, 5, 6, 7, 8} Find the following probabilities: Round to 3 decimal places. a. P(2) b. Plodd number) = c. P(not 7) = d. P(less than 6) = e. P(3.5) -

  • onsider rolling a fair 8 sided die. The sample space is S = {1, 2, 3,...

    onsider rolling a fair 8 sided die. The sample space is S = {1, 2, 3, 4, 5, 6, 7, 8} Find the following probabilities: Round to 3 decimal places. a. P(2) = b. P(odd number) = c. P(not 7) = d. P(less than 6) = e. P(3.5) =

  • Consider rolling a fair 8 sided die. The sample space is S = {1, 2, 3,...

    Consider rolling a fair 8 sided die. The sample space is S = {1, 2, 3, 4, 5, 6, 7, 8} Find the following probabilities: Round to 3 decimal places. a. P(2) = b. P(odd number) c. P(not 7) = d. P(less than 6) = e. P(3.5) =

  • Random Number Generation and Static Methods Write a program that simulates the flipping of a coin...

    Random Number Generation and Static Methods Write a program that simulates the flipping of a coin n-times to see how often it comes up heads or tails. Ask the user to type in the number of flips (n) and print out the number of times the coin lands on head and tail. Use the method ‘random()’ from the Math class to generate the random numbers, and assume that a number less than 0.5 represents a tail, and a number bigger...

  • I am using C++ Write a program to determine if a gird follows the rules to...

    I am using C++ Write a program to determine if a gird follows the rules to be classified as a Lo Shu Magic Square. The Lo Shu Magic Square is a grid with 3 rows and 3 columns shown in figure below. The Lo Shu Magic Square has the following properties: The grid contains the numbers 1 through 9 exactly. The sum of each row, each column, and each diagonal all add up to the same number. This is shown...

  • Write a Python (version 3.5.2) program that simulates how often certain hands appear in Yahtzee. In...

    Write a Python (version 3.5.2) program that simulates how often certain hands appear in Yahtzee. In Yahtzee, you roll five dice and then use those dice to make certain combinations. For example, the Yahtzee combination is formed by all five dice having the same value. A large straight occurs when all of the dice are in consecutive order (e.g., 1,2,3,4,5 or 2,3,4,5,6). If you haven’t played Yahtzee, you can find out more from various online sources such as Wikipedia. Once...

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