Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Object Oriented Databases Prentice Hall International Series In Computer Science

Authors: John G. Hughes

1st Edition

0136298745, 978-0136298748

More Books

Students also viewed these Databases questions

Question

Describe the ultimate attribution error.

Answered: 1 week ago