Skip to content

Instantly share code, notes, and snippets.

@dvjones89
Last active March 14, 2018 22:06
Show Gist options
  • Save dvjones89/e496bf250e9033b3cba77d1d1162c4b3 to your computer and use it in GitHub Desktop.
Save dvjones89/e496bf250e9033b3cba77d1d1162c4b3 to your computer and use it in GitHub Desktop.
Visual Basic.net code that reads an array of scores between 0 and 100 and builds up a result string of "S", M" and "P" values for Strong, Medium and Poor broadband scores.
Imports System
Public Class BroadbandScorer
Public Shared Sub Main()
'Declare array (list) of scores between 100 and 0
Dim broadband_scores as Integer() = {100, 60, 82, 20}
'We start with a string that is completely empty and we'll slowly add "S", "M" or "P" letters as appropriate.
Dim result_string As String = ""
' Loop over each score previously listed in the broadband_scores array (list), adding the appropriate letter (S, M or P) to the result string, as we go.
For Each score as Integer in broadband_scores
If score >= 80 Then
' Add an "S" to the result string, if the current broadband score is greater than or equal to 80
result_string += "S"
ElseIf score >= 30 Then
' Add an "M" to the result string, if the current broadband score is greater than 30
' Due to the ElseIf, this will only happen if we didn't already match the first comparison (>= 80)
result_string += "M"
Else
' Finally, if we didn't match on >= 80 or >= 30, the number must be lower than 30, so add a "P" to the result string
result_string += "P"
End If
Next
' Now that we've looped over all scores and built up the result_string, print it out to the user
System.Console.WriteLine("The result string is: " & result_string)
End Sub
End Class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment