Exercise
Function CountDV
Objetive
Create a function that calculates the amount of numeric digits and vowels that a text string contains. It will accept three parameters: the string that we want to search, the variable that returns the number of digits, and the number of vowels, in that order). The function should be called "CountDV". Use it like this:
CountDV ("This is the phrase 12", ref amountOfDigits, ref amountOfVowels)
In this case, amountOfDigits would be 2 and amountOfVowels would be 5
Code
Imports System
Public Class exercis122
Public Shared Sub CountDV(ByVal answer As String, ByRef amountOfDigits As Integer, ByRef amountOfVowels As Integer)
amountOfDigits = 0
amountOfVowels = 0
For i As Integer = 0 To answer.Length - 1
Select Case answer.Substring(i, 1).ToLower()
Case "a", "e", "i", "o", "u"
amountOfVowels += 1
Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
amountOfDigits += 1
End Select
Next
End Sub
Public Shared Sub Main()
Dim amountOfDigits As Integer = 0
Dim amountOfVowels As Integer = 0
CountDV("This", amountOfDigits, amountOfVowels)
Console.WriteLine(amountOfDigits)
Console.WriteLine(amountOfVowels)
End Sub
End Class