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

Given the following program interface and btnProcess() code, write the code for

ID: 647035 • Letter: G

Question

Given the following program interface and btnProcess() code, write the code for count() which counts the number of times the entered number occurs in the array.

Dim intNum() As Integer = {4, 5, 6, 3, 5, 4, 7, 6, 8, 7, 2, 1, 3, 2, 5, 6, 7, 4, 5, 3, 2, 8, 9, 7, 8, 6}

Private Sub btnProcess_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnProcess.Click

    Dim intTarget As Integer

    Dim intPos As Integer

    intTarget = Convert.ToInt32(TextBox1.Text)

    TextBox2.Text = count(intTarget)

End Sub

Given the following program interface and btnProcess() code, write the code for count() which counts the number of times the entered number occurs in the array. Array Demonstration Enter a number Process Data Results Dim intNum() As Integer = {4, 5, 6, 3, 5, 4, 7, 6, 8, 7, 2, 1, 3, 2, 5, 6, 7, 4, 5, 3, 2, 8, 9, 7, 8, 6} Private Sub btnProcess_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnProcess.Click Dim intTarget As Integer Dim intPos As Integer intTarget = Convert.ToInt32(TextBox1.Text) TextBox2.Text = count(intTarget) End Sub

Explanation / Answer

int count(int target)

Dim count_num As Integer = 0

int count(int target)

Dim count_num As Integer = 0

        For Each num As Integer In IntNum               If num = target Then count_num = count_num + 1         Next         Return count_num
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