Question

In: Computer Science

Create a dice simulator in C#. The simulator must roll the dice 6 times and it...

Create a dice simulator in C#. The simulator must roll the dice 6 times and it must add the 3 highest rolls. So say it simulates: 4 4 5 2 1 3 the total would be 13 (4+4+5=13). Repeat this 6 different times.

So if the random dice simulator simulates the outcomes below it should output: 13, 13, 14, 12, 16, 12

1) 4 4 5 2 1 3

2) 2 3 6 1 3 4

3) 5 3 1 4 6 2  

4) 4 2 2 1 1 6

5) 5 4 5 6 3 1

6) 1 2 4 5 3 2

Solutions

Expert Solution

C# code

============================================================================================

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace diceroll
{
class Program
{
static void Main(string[] args)
{
int []arr = new int[6];
int sum=0;
int count = 0;
Random random = new Random();

while (count < 6)
{


for (int i = 0; i < 6; i++)
{
arr[i] = random.Next(1, 7);
//Console.WriteLine(arr[i]);
}
//sort array
Array.Sort(arr);
sum = 0;
for (int i = 3; i < 6; i++)
sum = sum + arr[i];

Console.WriteLine("Dice roll Sum is:{0}", sum);
count++;
}

Console.WriteLine("Press Enter to continue ");

Console.ReadLine();
}
}
}

============================================================================================

Output


Related Solutions

Roll 3 times independently a fair dice. Let X = The # of 6's obtained. The...
Roll 3 times independently a fair dice. Let X = The # of 6's obtained. The possible values of the discrete random variable X are: 1.For the above random variable X we have P(X=2) equal to: 2.For the above random variable X we have P(X=3) equals to: 3.For the above random variable X we have P(X=3) equals to: 4.The Domain of the moment generating function of the above random variable X is: 5.The Domain of the moment generating function of...
PROJECT C Roll a 6-sided die 800 times. If you do not desire to roll a...
PROJECT C Roll a 6-sided die 800 times. If you do not desire to roll a die manually, STATDISK can be used to simulate the process. To use STATDISK, go to “Data” at the top of the STATDISK window, and then choose “Dice Generator”. The “Dice Roll Random Sample Generator” window will appear. Then in that window, put 800 in for “Sample Size”, put 1 in for “Num Dice”, and put 6 in for “Num Sides”. Please disregard the “Random...
1. Assume we roll 6 dice. What is the probability that the roll contains: a. 6...
1. Assume we roll 6 dice. What is the probability that the roll contains: a. 6 of the same number b. 3 of one number, 2 of a second number, and 1 non-matching number c. 3 pairs of different numbers
Fair Dice We roll a fair dice 10 times and register how many times we obtained...
Fair Dice We roll a fair dice 10 times and register how many times we obtained 5. (a) Find the probability to obtain 5 seven times. (b) Estimate the number of fives that will come out with the probability 0.35. (c) What is the probability of geting 30 fives when rolling a fair dice 45 times? (d) How many fives will come out with a probability of 0.25, when rollong a fair dice 45 times?
Roll two dice 48 times and record the sum of the spots on the top faces...
Roll two dice 48 times and record the sum of the spots on the top faces as you roll. Then construct a probability distribution for your 48 sums. Using the probability distribution, you constructed, find the mean number of spots. (If you don't have two dice, then cut out 6 pieces of paper with each being the same size and with #1,2,3,4,5,6 written on them. Place the pieces of paper in a hat or bowl. Pull out a number, then...
(5 pts) You are going to roll a pair of dice 108 times and record the...
(5 pts) You are going to roll a pair of dice 108 times and record the sum of each roll. Before beginning, make a prediction about how you think the sums will be distributed. (Each sum will occur equally often, there will be more 12s than any other sum, there will be more 5s than any other sum, etc.) Record your prediction here: (5 pts) Roll the dice 108 times and record the sum of each roll in the table...
(Using C++ create a Car Instrument Simulator) Car Instrument Simulator Create the following classes: Car, Odometer,...
(Using C++ create a Car Instrument Simulator) Car Instrument Simulator Create the following classes: Car, Odometer, FuelGauge. The Car class allows for the instantiation of a Car object. The Car object will contain (via composition) an Odometer object, and a FuelGauge object. The Car object will also include "make", "model", and "color" as string properties (instance variables). In the Car constructor method, you will create a FuelGauge object, passing 15 as an argument into the FuelGauge constructor indicating the number...
We roll the dice 20 times. The results we obtained are presented in the table. obtained...
We roll the dice 20 times. The results we obtained are presented in the table. obtained number 1 2 3 4 5 6 number of throws 1 1 7 4 4 3 a) The value of the relevant test statistics is: b) Assuming the significance level of 0.05, it can be considered that the dice used to roll IS / IS NOT FAIR
Our experiment is to roll 2 dice 900 times. The random variable, X, is the number...
Our experiment is to roll 2 dice 900 times. The random variable, X, is the number of times that the two dice add up to either 7 or 11. Find E(X), Var(X), and E(X^2). Assuming that the Central Limit Theorem applies, AND that the standard deviation is exactly 12.5, AND not bothering with the half-unit correction, find: P(X>225) P(X<175)
You roll two 6-sided dice numbered 1 through 6. Let A be the event that the...
You roll two 6-sided dice numbered 1 through 6. Let A be the event that the first die shows the number 3, let B be the event that the second die shows a 5, and let E be the event that the sum of the two numbers showing is even. Compute P(A)and P(B)and then compute P(AlB). What does this tell you about events A and B?Hint: Remember that the sample space has 36 outcomes! Compute P(ElA)and compute P(E). What does...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT