Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need help with the following code, also it needs to test every function! public class ExerciseFunctions{ /** Boolean function returns true if the given
I need help with the following code, also it needs to test every function! public class ExerciseFunctions{ /** Boolean function returns true if the given string begins with "win", except the 'w' can be anything, so "win", "fin", "pin", "8in" .. all count. winCondition("win prizes") true winCondition("pin the tail") true winCondition("wit fries?") false winCondition("pit viper") false */ public static boolean winCondition(String original) { boolean returnValue = false; //Your code here return returnValue; } /** @return the largest of three given int values. maxInt(1, 2, 3) 3 maxInt(3, 2, 3) 3 maxInt(2, 5, 3) 5 maxInt(7, 5, 4) 7 */ public static int maxInt(int first, int second, int third) { int returnValue = 0; //Your code here return returnValue; } /** @return true only if both input strings are "naughty". isNaughty("naughty", "naughty") true isNaughty("naughty", "any-string") false isNaughty("any-string", "naughty") false isNaughty("any-string", "any-string") false */ public static boolean isNaughty(String firstString, String secondString) { boolean returnValue = false; //Your code here return returnValue; } /** @return true if either input string is "nice". isNice("nice", "any-string") true isNice("any-string", "nice") true isNice("nice", "any-string") true isNice("any-string", "any-string") false */ public static boolean isNice(String firstString, String secondString) { boolean returnValue = false; //Your code here return returnValue; } /** @return of two int values, whichever is closer to ten. In the event of a tie return 0. Note that Math.abs(n) returns the absolute value of a number. nearest10(8, 13) 8 nearest10(13, 8) 8 nearest10(13, 7) 0 */ public static int nearest10(int firstNumber, int secondNumber) { int returnValue = 0; //Your code here return returnValue; } /** Boolean function takes two non-negative int values as input. @return true if they have the same last digit, such as with 27 and 57. Note that the % "mod" operator computes remainders, so 27 % 10 is 7. sameLastDigit(3, 3) true sameLastDigit(7, 17) true sameLastDigit(6, 17) false sameLastDigit(3, 113) true */ public static boolean sameLastDigit(int firstNumber, int secondNumber) { boolean returnValue = false; //Your code here return returnValue; } /** @return given a string of the form I love any-thing" returns "any-thing loves you" if the input is not of the form "I love any-thing" the function returns the string "Fred Rogers 143" lovesYou("I love TAMU") "TAMU loves you" lovesYou("I love Basketball") "Basketball loves you" lovesYou("") "Fred Rogers 143" lovesYou("any thing else") "Fred Rogers 143" */ public static String lovesYou(String original) { String returnValue = ""; //Your code here return returnValue; } /** @return Given a String, removes the characters 22 if they occur. If 22 occurs at the end or beginning of the input String remove any whitespace that occurs at the beginning or end of the String. catch22("Catch 22") "Catch" catch22("22 Rifle") "Rifle" catch22("Bottles of beer, 22 on the Wall") "Bottles of beer, on the Wall" ** Note this function does not need to remove whitespace inside the string **Beer example output contains 2 spaces resulting when 22 was removed ** */ public static String catch22(String original) { String returnValue = ""; //Your code here return returnValue; } /** @return given a String, that String with the first character of each input word capitalized. formalWords("hi") "Hi" formalWords("This is our finest hour") "This Is Our Finest Hour" */ public static String formalWords(String original) { String returnValue = ""; //Your code here return returnValue; } /** @return given an input String, that String with all English articles (the, an, a) removed. deleteArticles("cat") "cat" deleteArticles("a cat") "cat" deleteArticles("The cat in a hat") "cat in hat" ** Note more strict whitespace removal required in this function ** You can assume that replacing double-spaces with single-spaces is always OK. */ public static String deleteArticles(String original) { String returnValue = ""; //Your code here return returnValue; } }
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