December 22, 2024

Answer to Collections Q9

 

| word numberOfVowels |
word := 'Ultrarevolutionaries'.
numberOfVowels := 0.
1 to: word size do: [ :index | | letter |
   letter := word at: index.
(letter isVowel )
   ifTrue: [ numberOfVowels := numberOfVowels + 1] ].
Dialog warn:
   word,' contains ',numberOfVowels printString,' vowels.'.

 

Back to « Collection Questions 2

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Up to top of page