Question: Finish the following methods: public class SomeStringMethods { /* returns the index of the first Roman Numeral in s or -1 * if s contains

Finish the following methods:

public class SomeStringMethods {

/* returns the index of the first Roman Numeral in s or -1 * if s contains no Roman Numerals */ public static int indexOfFirstRomanNumeral(String s) { return -1; }

/* returns the index of the first occurrence of a roman numeral * in s starting from index startPosition or -1 if * there are no roman numerals 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 indexOfFirstRomanNumeral(String s, int startPosition) { return -1; }

/* returns the index of the last occurrence of a roman numeral in * s or -1 if s contains no roman numerals */ public static int indexOfLastRomanNumeral(String s) { return -1; }

/* returns true if the first, last, and middle letter of s is the * same ignoring case or false otherwise. * Returns false if s is shorter than 3 characters * * (Note: when there are an odd number of letters in a word, * for example, the word radar, it's clear what the middle * letter is. What would it mean to be the middle letter * for a word with an even number of letters?) */ public static boolean sameFirstLastMiddle(String s) { return true; }

/* 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 Roman Numerals removed. For example, if s is "windmill" * the method returns "wn" */ public static String deRomaned(String s) { return ""; }

/* Returns a new String that looks like base appended with suffix. If base already ends with suffix, it returns base. For example, if base is "lightning" and suffix is "bug", returns "lightningbug". If base is "lightningbug" and suffix is "bug", it also returns "lightningbug". */ public static String appendIfMissing(String base, String suffix) { return ""; }

/* 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) { return -1; } }

HELP PLEASE!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!