74.8k views
1 vote
JAVA

In this exercise, you are given a phrase that starts with ‘A’. If the word after ‘A’ begins with a vowel, add an ‘n’ after the ‘A’, otherwise, return the phrase as is.

Example:

grammer("A word") --> "A word"
grammer("A excellent word") --> "An excellent word"


public String grammar(String phrase)
{
}

User Reefaq
by
3.9k points

1 Answer

5 votes

Answer:

Answer is provided in the attached screenshot

Step-by-step explanation:

The character in the 2nd position will be always be the one we need to check. We then check if that character is a vowel, and replace the string as required.

JAVA In this exercise, you are given a phrase that starts with ‘A’. If the word after-example-1
User Thai Nguyen Hung
by
4.4k points