Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You are to create a Visual Basic 2010 application that will roll a pair of dice

ID: 3529108 • Letter: Y

Question

You are to create a Visual Basic 2010 application that will roll a pair of dice one hundred times and compute the mean and standard deviation of the rolls (the total of the two dice). Also, your application should show a table that shows each possible roll of the dice and its frequency of occurrence in the simulation in a listbox. In other words, the table shows the count of a roll of 2, the count of a roll of 3, and so on up to a roll of 12. there is no input for this program, the button is clicked and it displays all of the values in a listbox and then the Standard deviation and mean are displayed in two other textboxes

Explanation / Answer

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click txtDeviation.Enabled = True txtMean.Enabled = True Dim die1, die2 As Integer Dim dicesum As Integer Dim twos, threes, fours, fives, sixes, sevens, eights, nines, tens, elevens, twelves As Integer Dim numberofrolls As Integer Dim randomnum As New Random Do die1 = randomnum.Next(1, 7) die2 = randomnum.Next(1, 7) numberofrolls += 1 Loop Until (numberofrolls = 100) If die1 + die2 = 2 Then twos += 1 End If If die1 + die2 = 3 Then threes += 1 End If If die1 + die2 = 4 Then fours += 1 End If If die1 + die2 = 5 Then fives += 1 End If If die1 + die2 = 6 Then sixes += 1 End If If die1 + die2 = 7 Then sevens += 1 End If If die1 + die2 = 8 Then eights += 1 End If If die1 + die2 = 9 Then nines += 1 End If If die1 + die2 = 10 Then tens += 1 End If If die1 + die2 = 11 Then elevens += 1 End If If die1 + die2 = 12 Then twelves += 1 End If ListBox1.Items.Add("Roll Frequency") ListBox1.Items.Add("=====================") ListBox1.Items.Add("2 " & twos) ListBox1.Items.Add("3 " & threes) ListBox1.Items.Add("4 " & fours) ListBox1.Items.Add("5 " & fives) ListBox1.Items.Add("6 " & sixes) ListBox1.Items.Add("7 " & sevens) ListBox1.Items.Add("8 " & eights) ListBox1.Items.Add("9 " & nines) ListBox1.Items.Add("10 " & tens) ListBox1.Items.Add("11 " & elevens) ListBox1.Items.Add("12 " & twelves) dicesum = die1 + die2 txtMean.Text = FormatNumber(dicesum / 100, 2) End Sub End Class

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote