Week 6: Text 1
Write a program that counts the number of words in a sentence that the user enters.
E.g. We don’t need no education should display 5.
Scrivi un programma per contare il numero di parole in una frase inserita dall’utente.
Soluzione
TextWindow.Write("Testo: ")
testo=TextWindow.Read()
contatore=1
For i=2 To Text.GetLength(testo)-1
If Text.GetSubText(testo, i, 1) = " " Then
contatore=contatore+1
EndIf
EndFor
TextWindow.WriteLine(contatore)