Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3.2 Task 2: getVowels () Write a method getVowels that takes a string as parameters and returns the number of vowels present in that

image text in transcribed

3.2 Task 2: getVowels () Write a method getVowels that takes a string as parameters and returns the number of vowels present in that string. Vowels of the English alphabet are the letters: a, e, i o, and u. The string can be in upper case or lower case letters, or contain both upper and lower case letters. Hint: use the String class method charAt(index) that returns the character at a given index. Examples: Call getVowels ("Hello") Value Returned 2 getVowels ("I love JAVA") 5 getVowels (AbEeRr) 2 3.3 Task 3: switchLetterCase() Write a method switchLetterCase that takes a string as an input. The method should identify whether the characters in the string are in uppercase or lowercase, then changes all the lowercase characters, if any, to uppercase and vice versa. Hint: Use the isLowerCase() method (returns a Boolean) in the Character class by making the call Character.isLowerCase(char c). It identifies if the character is in lower case mode or not. Also, use the methods of the String class such as charAt(index) that returns the character at a given index of the string, and substring() to get part of the string). Examples: Call switchLetterCase ("Hello") switchLetterCase("I love JAVA") switchLetterCase("York UNIV.") Value Returned "HELLO" "i LOVE java" "YORK univ.

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

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions