Question
How would I code the 100 point version so that it outputs the Expected output? Student Version of StringMethods: public class StringMethods { /* *
How would I code the 100 point version so that it outputs the Expected output?
Student Version of StringMethods: public class StringMethods { /* * method getFirst() returns all letters before the delimiter in line */ public static String getFirst( String line, String delimiter ) { return ""; } /* * method getLast()returns all letters after the delimeter in line */ public static String getLast( String line, String delimiter ) { return ""; } /* * method removeComma() if there is a comma in parameter word, * returns word without the comma; else returns word */ public static String removeComma( String word ) { return ""; } /* * method getNumUpper() returns the number of uppercase letters in line. */ public static int getNumUpper( String line ) { return 0; } /* * method displayWords() displays the individual words, * one per line, in the parameter phrase */ public static void displayWords(String phrase) { } public static void main( String args[] ) { // test methods getFirst and getLast - 80 pt version System.out.println( getFirst("elephants@are@big", "@") ); System.out.println( getFirst("computer$science", "$") );
System.out.println( getFirst("dogs@are@not@smarter@than@cats", "@") ); System.out.println( getFirst("one#fish#blue#fish", "#") ); System.out.println( getLast("elephants@are@big", "@") ); System.out.println( getLast("computer$science", "$") ); System.out.println( getLast("dogs@are@not@smarter@than@cats", "@") ); System.out.println( getLast("one#fish#blue#fish", "#") ); System.out.println(" "); // test method getNumUpper - 90 pt version System.out.println(" Number of uppercase letters in: "); String line = "Computer Science"; System.out.println(line + " : " + getNumUpper(line)); line = "AP " + line; System.out.println(line + " : " + getNumUpper(line)); line = "The Cat in the Hat Comes Back by Dr. Suess"; System.out.println(line + " : " + getNumUpper(line)); // test remove comma - 100 pt version System.out.println(" Remove comma"); System.out.println( removeComma("Tweety,Bird")); System.out.println( removeComma("Sylvester")); System.out.println( removeComma(",YosemiteSam")); // display the words, one per line in the string - 110 pt version line = "I love unicorns"; System.out.printf(" \"%s\" contains the words: ", line ); displayWords(line); line = "Did I ever tell you that Mrs. McCave had twenty-three sons and she named them all Dave?"; System.out.printf(" \"%s\" contains the words: ", line ); displayWords(line); } }
Lab StringMethods 80, 90, 100, and 110 point versions Lab Goal This lab was designed to teach you more about the String class methods Lab Description: class You are provided with a StringMethods class. You are to complete the methods in the Student Version of StringMethods public class StringMethods method getFirst) returns all letters before the delimiter in line public static String getFirst( String line, String delimiter ) return" * method getlast ) returns all letters after the delimeter in line public static String getliast String line, String delimiter) return "" * method removeComma) if there is a comma in parameter word, returns word without the comma; else returns word public static String removeComma ( String word ) return "; * method getNumUpper ) returns the number of uppercase letters in line. public static int getNumUpper String line) return 0; * method displayWords ) displays the individual words, * one per line, in the parameter phrase public static void displayWords (String phrase) public static void main String args[ ) // test methods getFirst and getLast 80 pt version System.out.printin getFirst ("elephants@are@big", "a"); System.out.println getFirst ("computerSscience", "")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