Advertisement
MiroJoseph

Vowel Count

Apr 4th, 2020
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.43 KB | None | 0 0
  1. object Sol {
  2.  
  3.   def getCount(inputStr: String, counter:Int=0): Int = {
  4.   if (counter<inputStr.length())
  5.     inputStr(counter) match{
  6.     case 'a'=>getCount(inputStr,counter+1)+1
  7.     case 'e'=>getCount(inputStr,counter+1)+1
  8.     case 'i'=>getCount(inputStr,counter+1)+1
  9.     case 'o'=>getCount(inputStr,counter+1)+1
  10.     case 'u'=>getCount(inputStr,counter+1)+1
  11.     case _ =>getCount(inputStr,counter+1)
  12.     }
  13.     else 0
  14.   }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement