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

Could somebody please do this in Visual Basic. Thank you! Program 3: Statistics

ID: 3769227 • Letter: C

Question

Could somebody please do this in Visual Basic. Thank you!

Program 3: Statistics

In statistics there are a number of different indicator values that play important roles in data analysis. We will find three: mean, median, mode. The mean of values is the arithmetic average of the values -that is add them all together and divide by the number of items. The median in a set that has an odd number of items is the middle value – in an even set it is the mean of the two center most values. Lastly, the mode is the number that appears most often (there can be more than one).

Consider          2, 3, 4, 5, 6, 7, 7, 8, 8, 8, 8

The mean is 6.                         The median is 7.          The mode is 8.

Create a program that takes in ten values from the user and store them in a list box. The program should then determine and display the mean, median and mode of those values.

Explanation / Answer

Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_sort.Click 'Declaring variables Dim Num1 As Integer Dim Num2 As Integer Dim Num3 As Integer Dim Num4 As Integer Dim Num5 As Integer Dim Num6 As Integer Dim Num7 As Integer Dim Num8 As Integer Dim Num9 As Integer Dim Num10 As Integer 'Declaring which textboxes are which variables Num1 = TextBox1.Text Num2 = TextBox2.Text Num3 = TextBox3.Text Num4 = TextBox4.Text Num5 = TextBox5.Text Num6 = TextBox6.Text Num7 = TextBox7.Text Num8 = TextBox8.Text Num9 = TextBox9.Text Num10 = TextBox10.Text 'Mean 'Add all numbers together and divide by nine. TextBoxMean.Text = (Num1 + Num2 + Num3 + Num4 + Num5 + Num6 + Num7 + Num8 + Num9 + Num10) / 10 'Median Dim numbers() As Integer = {Num1, Num2, Num3, Num4, Num5, Num6, Num7, Num8, Num9, Num10} Array.Sort(numbers) If numbers.Length Mod 2 0 Then 'uneven amount of numbers 'MsgBox("Median = " & numbers(numbers.GetUpperBound(0) 2).ToString) TextBoxMedian.Text = ("" & numbers(numbers.GetUpperBound(0) 2).ToString) End If 'Mode Dim Mode() As Integer = {Num1, Num2, Num3, Num4, Num5, Num6, Num7, Num8, Num9, Num10} Array.Sort(Mode) Dim lnum As Integer = 0, lcount As Integer = 0 Dim i As Integer = 0 While i lcount Then lnum = Mode(i - 1) lcount = ccount End If End If End If i += 1 End While End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_generate.Click 'Generates a random number out of 100. Randomize() TextBox1.Text = Int(Rnd() * 100) TextBox2.Text = Int(Rnd() * 100) TextBox3.Text = Int(Rnd() * 100) TextBox4.Text = Int(Rnd() * 100) TextBox5.Text = Int(Rnd() * 100) TextBox6.Text = Int(Rnd() * 100) TextBox7.Text = Int(Rnd() * 100) TextBox8.Text = Int(Rnd() * 100) TextBox9.Text = Int(Rnd() * 100) TextBox10.Text = Int(Rnd() * 100) End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_exit.Click Close() 'Closes the program End Sub End Class