Given an Integer variable k, an Integer array incompletes that has been declared and initialized, an int variable studenID that has been initialized, and an int variable numberOfIncompletes, write code that counts the number of times the value of studentID appears in incompletes and assigns this value to numberOfIncompletes. You may use only k, incompletes, studentID, and numberOfIncompletes.

LANGUAGE: Visual Basic

CHALLENGE:

Given an Integer variable k, an Integer array incompletes that has been declared and initialized, an int variable studenID that has been initialized, and an int variable numberOfIncompletes, write code that counts the number of times the value of studentID appears in incompletes and assigns this value to numberOfIncompletes.
You may use only k, incompletes, studentID, and numberOfIncompletes.

SOLUTION:


numberOfIncompletes = 0
For k = 0 to (incompletes.length-1)
    If studentID = incompletes(k) Then
        numberOfIncompletes += 1
    End If
Next