Question: IN SCALA Write a function named countVowels that inputs a String and outputs an Int which counts the number of occurrences of a vowel in

IN SCALA

Write a function named countVowels that inputs a String and outputs an Int which counts the number of occurrences of a vowel in a given string. Vowels are a, e, i, o, u. Capital letters of vowels should also count as a vowel.

Example:

Input: "aaatchoU"

Output: 5.

You may use for-loops/while loops and mutable vars for this particular problem. String or List API functions are also allowed.

Your program should pass the following tests:

testWithMessage( countVowels("atchou") , 3, "\"atchou\" must have three vowels in it" )

testWithMessage( countVowels(""), 0, "Empty string has no vowels")

testWithMessage( countVowels("AAEIOU"), 6, "Capitalized vowels handled")

testWithMessage( countVowels("Grzzly"), 0, "\"Grzzly\" has no vowels")

testWithMessage( countVowels("Meow, Meow, says the alley cat next door!!"), 12, "Handling commas and spaces?")

score=(score*1*10/5.0).round / 1.0

passed(score)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!