Question

Write a program that simulates a throw of two 900-sided dice and indicates whether or not...

Write a program that simulates a throw of two 900-sided dice and indicates whether or not the sum of the results is divisible by three?

Homework Answers

Answer #1

Required code in C++ -->

#include <iostream>
#include <random>
int main()
{
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<> distr(1, 900);
int x=distr(gen); // a random value will be stored in x
std::cout<<"we get"<<x<<"\n"; // x will be displayed
int y=distr(gen); // a random value will be stored in y
std::cout<<"we get"<<y<<"\n"; // y will be displayed
int sum=x+y; // addition of x,y will be stored in sum
if(sum%3==0){ // if sum is divisible by 3
std::cout<<"Divisible by 3"; // output - divisible by 3
}
else{
std::cout<<"Not Divisible by 3"; //else not divisible
}
}

Know the answer?
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
Similar Questions
Use MATLAB Write a script that simulates a dice throw, randomly printing to the screen (with...
Use MATLAB Write a script that simulates a dice throw, randomly printing to the screen (with equal probability) one of the integers from 1 to 6. Call your script DiceThrow.m EXTRA CREDIT (100%) Write a script that simulates a loaded dice throw, randomly printing to the screen one of the integers from 1 to 6, but with 6 twice as likely as all the others. Call your script LoadedDiceThrow.m
I need this coded in R: I have a program that simulates a fair dice. The...
I need this coded in R: I have a program that simulates a fair dice. The program rolls a fair coin 100 times and counts the number of 1's. The simulation is repeated 10^5 times and stored the outcomes in x and a histogram is plotted. I need to now draw a bell curve showing normal/gaussian distribution over the histogram. Code I have: dice <- function(n) { sample(c(1:6),n,replace = TRUE) } x<-dice(100) x<-numeric(10^5) for(n in 1:10^5){ x[n]<-sum(dice(100)==1) } hist(x, main="100...
An experiment consists of rolling two 6-sided dice. Find the probability that the sum of the...
An experiment consists of rolling two 6-sided dice. Find the probability that the sum of the dice is at most 5. Write your answer as a simplified fraction, i.e. a/b
Throw two dice. If the sum of the two dice is 7 or more, you win...
Throw two dice. If the sum of the two dice is 7 or more, you win $15. If not, you pay me $17. Step 1 of 2 :   Find the expected value of the proposition. Round your answer to two decimal places. Losses must be expressed as negative values.
Consider a game where two 6-sided dice are rolled. - Let X be the minimum of...
Consider a game where two 6-sided dice are rolled. - Let X be the minimum of the two dice - Let Y be the sum of the two dice - Let Z be the first die minus the second die. Write out the distributions of X, Y, and Z, respectively.
Throw two dice. If the sum of the two dice is 6 or more, you win...
Throw two dice. If the sum of the two dice is 6 or more, you win $14. If not, you pay me $29. If you played this game 964 times how much would you expect to win or lose? Round your answer to two decimal places. Losses must be answered as negative.
Suppose you roll, two 6-sided dice Write any probability as a decimal to three place values...
Suppose you roll, two 6-sided dice Write any probability as a decimal to three place values and the odds using a colon. Determine the following: 1. The probability that you roll a sum of seven (7) 2. The odds for rolling a sum of four (4) is 3. The odds against the numbers on both dice being the same is Suppose you have a bag with the following marbles: four (4) red, six (6) pink, two (2) green, and seven...
For the following questions, find the probability using a standard 6-sided die or two 6-sided dice....
For the following questions, find the probability using a standard 6-sided die or two 6-sided dice. Write your answer as a fraction or with a colon in lowest terms. Rolling a single die, what is the probability of rolling an even number? Rolling a single die, what is the probability of rolling a 5? Rolling a single die, what is the probability of rolling a 7? Rolling a single die, what is the probability of rolling a number less than...
Four fair six sided dice are rolled. Given that at least two of the dice land...
Four fair six sided dice are rolled. Given that at least two of the dice land on an odd number, what is the probability that the sum of the result of all four dice is equal to 14?
(5) Rolling two four-sided dice, what’s the likelihood of getting the same result (i.e., the same...
(5) Rolling two four-sided dice, what’s the likelihood of getting the same result (i.e., the same sum) twice in a row? (5) Rolling three four-sided dice, what is the probability of totaling at least 9? (5) Rolling three four-sided dice twice, what is the expected total? (5) Rolling three four-sided dice twice, what is the probability of actually getting exactly the expected total from Problem 8? (10) Rolling three four-sided dice twice, what is the probability of the second total...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT