/************************************ Author: PUT YOUR NAME HERE Date created: 18 Aug 2020 Date last modified: 18 Aug 2020 Program: stringPlay.py ************************************/ /*****************sample solution********** ***************Problem 0******************/ public class StringFunctions { /* arg is a string in which the specified letter occurs at least twice, letter is a one-character string this function returns a new string with the characters between the first and last instance of letter in the string*/ public static String get_between(String arg, char letter) { int start = arg.indexOf(letter); int end = arg.lastIndexOf(letter); return arg.substring(start + 1, end); } //You have a solution manual. Look in the main //method for a sample test. //Create at least one for each function. /***************Problem 1***************** arg is a string, letter is a one-character string remove all instances of letter from arg, both upper and lower case*/ public static String remove_letter(String arg, char letter) { return ""; } /***************Problem 2***************** /*arg is guaranteed to have at least two letters and to be an alphabetical string return a string with the first and last letters of arg.*/ public static String eviscerate(String arg, char letter) { return ""; } /***************Problem 3***************** /*head has an even number of letters tail has an even number of letters return a string whose first half is the first half of head and the second half of tail.*/ public static String frankenstein(String head, String tail) { return ""; } /***************Problem 4***************** arg is a string, letter is a character returns the number of times letter appeaers in arg, case insensitive */ public static int letter_count(String arg, char letter) { return 0; } /***************Problem 5***************** "arg is a string, letter is a one-character string, and n is an integer 0 <= n <= len(letter) return the number of instances of letter in the first n characters of the string arg*/ public static int letter_count_partial(String arg, char letter, int n) { return 0; } /****************Problem 6***************** """arg is a string, ch is a one-character string and n is an integer, n >= 0 returns the string arg centered in a string of length n, padded with character ch. If n < len(arg), it just returns arg(no conditional logic on your part needed)*/ public static String marquee(String arg, char ch, int n) { return ""; } /***************Problem 7***************** arg is any string get rid of all of the whitespace on the left, if any replace any spaces on the right with ch and return the result.*/ public static String doodle(String arg, char ch) { return ""; } public static void main(String[] args) { String arg = "quoque"; char letter = 'q'; String result = "uo"; System.out.println(result.equals(get_between(arg, letter))? "PASS":"FAIL"); arg = "robber"; letter = 'r'; result = "obbe"; System.out.println(result.equals(get_between(arg, letter))? "PASS":"FAIL"); //possible grist for a test case, problem 1 arg = "Sissyphus"; result = "iyphu"; //grist for test on #2 // arg = "heinous"; result = "hs"; arg = "Washington"; result = "Wn"; //test #3 String head = "cerebellum"; String tail = "wagger"; result = "cereger"; //test grist. #4 arg = "Babbage"; letter = 'b'; int count = 3; //grist for testing, #5 arg = "Babbage"; count = 3; arg = "flibbertygibbet"; count = 2; //* test grist, #6 Make it work like Python arg = "wabbit"; result = "!!!!!!!!!!!!wabbit!!!!!!!!!!!!"; //test grist, #7 Make it work like Python arg = " wabbit "; result = "wabbit@@@@"; } }