write a console app code for this pseudocode

horsecrap

New member
Joined
Nov 19, 2008
Messages
1
Programming Experience
Beginner
hey, i need to convert this psedocode into a console mode programe for vb.net 2005 and i dont have a clue how to do it.
im getting confused with the functions bit
so let me know if any of you can make a solution
basically the user writes a sentence and the code is meant to count the spaces between the words and output the number of words written, and then the number of vowels written.
heres the pseudocode:

output "Sentence Analysis"
leave blank line
output "Enter a sentence, then press 'Enter'"
leave blank line
input Sentence
leave blank line
call procedure WordCount(Sentence)
call procedure VowelCount(Sentence)


thankyou
 
Learn about Console class. You can look up stuff like this in Help also.
 
In the main function:
VB.NET:
Console.WriteLine("Sentence Analysis" & vbCrLf)
Console.WriteLine("Enter a sentence, then press Enter:")
Dim strSentence as String = Console.ReadLine
Console.WriteLine(vbCrLf & "Word Count: " & WordCount(strSentence).ToString())
Console.WriteLine(vbCrLf & "Vowel Count: " & VowelCount(strSentence).ToString())

Then after the End Sub for the Main() function, insert these two functions:
VB.NET:
Private Function WordCount(ByVal strSentence As String) As Integer
Return strSentence.Split(" ").Length
End Function

Private Function VowelCount(ByVal strSentence As String) As Integer
Dim intVCount = 0
For Each c as Char In strSentence
If (c = "a") Or (c = "e") Or (c = "i") Or (c = "o") Or (c = "u") Or (c = "y") Then
intVCount += 1
End If
Loop
Return intVCount
End Function

I've been coding Javascript for the past couple of weeks and I don't have access to a debugger at the moment, but the above code should work. Try it out. :)
 

Similar threads

Back
Top