Question
Hello, I could use some help with the following assignment In this assignment, you'll practice what you've learned about static methods and gain more experience
Hello, I could use some help with the following assignment
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( ) is worth 12 points. Each other method is worth 4 points.
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 in any other method.
starter code
import java.util.Scanner; public class StringMethods { /* returns true if c is an upper case or lower case vowel * or false otherwise */ public static boolean isVowel(char c) { return true; } /* returns the index of the first vowel in s or -1 * if s contains no vowels */ public static int indexOfFirstVowel(String s) { return -1; } /* returns the index of the first occurrence of a vowel * in s starting from index startPosition or -1 if * there are no vowels in s at index startPosition or later */ /* notice that this method has the same name as the previous * one, but that it takes a different number of arguments. * This is perfectly legal in Java. It's called "method overloading" */ public static int indexOfFirstVowel(String s, int startPosition) { return -1; } /* returns the index of the last occurrence of a vowel in * s or -1 if s contains no vowels */ public static int indexOfLastVowel(String s) { return -1; } /* returns s in reverse. For example, if s is "Apple", the method * returns the String "elppA" */ public static String reversed(String s) { return ""; } /* returns the number of times that n occurs * in h. For example, if h is "Mississippi" and n is "ss" * the method returns 2. */ public static int numOccurrences(String h, String n) { return -1; } /* returns true if s is the same backwards and forwards * and false otherwise */ public static boolean sameInReverse(String s) { return false; } /* returns a new String which is the same as s, but with * all of the vowels removed. For example, if s is "summer vacation" * the method returns "smmr vctn" */ public static String devoweled(String s) { return ""; } /* Returns a new string consisting of all of the characters of s1 * and s2 interleaved with each other. For example, if s1 is * "Spongebob" and s2 is "Patrick", the * function returns the string "SPpaotnrgiecbkob" */ public static String zipped(String s1, String s2) { return ""; } /* returns a new String consisting of all of the letters * of s, but where tab characters ('\t') are replaced * with n spaces */ public static String tabToSpace(String s, int n) { return ""; } /* returns true if all of the characters in chars are * found in the String s, or false otherwise */ public static boolean containsAll(String s, String chars) { } /* returns the index of the first occurrence of any of the * characters in chars in String s or -1 if none of the characters * in chars are found in s. */ public static int indexOfAny(String s, String chars) { } public static void main(String args[]) { /* insert code to test each method */ } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started