Please help me with this Java program description In this assignment, you\'ll pr
ID: 3593973 • Letter: P
Question
Please help me with this Java program
description In this assignment, you'll practice what you've learned about static methods and gain more experience using Strings Fill in the missing static methods in the following code. You're welcome to copy and paste what's here. main worth 13 points. Each other method is worth 4 points. is It's highly recommended that you use methods that you've written already to help program other methods. For example, it's a very good idea to use your isVowel) in the more complicated methods involving vowels. Similarly, you might consider using your reversed) method in your sameInReverse method. The only place where you should print or read input from a scanner is in main). Do not print or read input from a Scanner in any other method. testing Your main will be used to test your methods. You'll call each of your methods and make sure that they return the desired results. When testing numoccurrencesyou might write something like: if (numOccurrences ("banana", "na")!-2) ( PRINT SOME ERROR MESSAGE QUIT h else System.out.println( "numOccurrences ): ok") For methods that return strings, don't forget about the .equals come in handy. and.equalsIgnorecase() methods. They mightExplanation / Answer
import java.util.Scanner;
public class StringMethods {
public static boolean isVowel(char c) {
return c == 'a' || c == 'e' || c =='i' || c == 'o' || c =='u';
}
public static int indexOfFirstVowel(String s) {
for (int i = 0; i < s.length(); i++) {
if (isVowel(s.charAt(i))) {
return i;
}
}
return -1;
}
public static int indexOfFirstVowel(String s, int startPosition) {
for (int i = startPosition; i < s.length(); i++) {
if (isVowel(s.charAt(i))) {
return i;
}
}
return -1;
}
public static int indexOfLastVowel(String s) {
for (int i = s.length() -1 ; i >= 0; i--) {
if (isVowel(s.charAt(i))) {
return i;
}
}
return -1;
}
public static boolean sameFirstLastMiddle(String s) {
if (s.length() < 3) return false;
int mid = s.length()/2;
return Character.toLowerCase(s.charAt(s.length()-1)) == Character.toLowerCase(s.charAt(0)) &&
Character.toLowerCase(s.charAt(0)) == Character.toLowerCase(s.charAt(mid));
}
}
As per policy doing first 4 parts.
P.S. Posting copy pastable code increase chance of more questions (or even more parts being done as it consume less time)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.