3.5.4: porky pig hey 3.5.4: public String yell(String text) { String a = text.toUpperCase(); return a; } 3.5.5: public String porkyPig(String something) { String a = "Bdap bdap bb " + something; 3.5.4: porky pig How to use it? 3.5.4: porky pig return a; } 3.5.6: public String tripleString(String str) { String a = str + "!" + str + "!" + str; return a; } 3.5.7: public String fullName(String first, String last) 3.5.4: porky pig How to dowload it? 3.5.4: porky pig { String a = last + ", " + first; return a; } 3.5.8: public String repeatString(String str, int n) { StringBuilder sb = new StringBuilder(); for(int i = 0; i < n; i++) { 3.5.4: porky pig How to use it? 3.5.4: porky pig sb.append(str); } return sb.toString(); } 3.6: public boolean isInteger(String str) { for(int i = 0; i < str.length(); i++) { if(Character.isDigit(str.charAt(i))) 3.5.4: porky pig How to get it for free? 3.5.4: porky pig { if(Character.isLetter(str.charAt(1))) { return false; } return true; } } if(str.contains("")) { 3.5.4: porky pig How to use it? 3.5.4: porky pig return false; } return false; } 3.7: public class BugHunter extends ConsoleProgram { public void run() { String test1 = "Debug"; 3.5.4: porky pig How to dowload it? 3.5.4: porky pig String test2 = "bugs bunny"; String test3 = "boogie"; String test4 = "baby buggie"; int index1 = findBug(test1); int index2 = findBug(test2); int index3 = findBug(test3); int index4 = findBug(test4); printBug(test1, index1); 3.5.4: porky pig PasteShr 3.5.4: porky pig printBug(test2, index2); printBug(test3, index3); printBug(test4, index4); } // Returns the index of the String "bug" inside the String str // If str does not contain the String "bug", returns -1 public int findBug(String str) { return str.indexOf("bug"); 3.5.4: porky pig How to get it? 3.5.4: porky pig } public void printBug(String test, int index) { if(index != -1) { System.out.println(test + " has a bug at index " + index); } else { 3.5.4: porky pig How to get it? 3.5.4: porky pig System.out.println(test + " has no bugs"); } } } 3.8 (in order): public String sumString(int one, int two) { int a = one + two; return one + " + " + two + " = " + a; } 3.5.4: porky pig How to get it? 3.5.4: porky pig ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- public String toUpperCase(String str) { String result = ""; for(int i = 0; i <= str.length() - 1; i++) { char a = Character.toUpperCase(str.charAt(i)); result += Character.toString(a); if(a == 'a') { 3.5.4: porky pig How to get it for free? 3.5.4: porky pig result += 'a' + 'a'; } } return result; } ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ public String doubleVowel(String str) { char[] v = {'a', 'e', 'i', 'o', 'u'}; String result = ""; 3.5.4: porky pig PasteShr 3.5.4: porky pig for(int i = 0; i <= str.length() - 1; i++) { if((str.charAt(i) + "").matches("a|e|i|o|u|A|E|I|O|U")) { result += str.charAt(i); } result += str.charAt(i); } return result; } 3.5.4: porky pig How to get it? 3.5.4: porky pig --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- public boolean allSameLetter(String str) { if(str.length() == 0) { return true; } for(int i = 1; i < str.length(); i++) { if(str.charAt(0) != str.charAt(i)) 3.5.4: porky pig PasteShr 3.5.4: porky pig { return false; } } return true; } --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- public String altCase(String text) { String r = ""; 3.5.4: porky pig PasteShr 3.5.4: porky pig int j = 0; for(int i = 0; i < text.length(); i++) { j++; char a = text.charAt(i); char b; if(j % 2 == 0) { b = Character.toLowerCase(a); r += b; 3.5.4: porky pig How to get it for free? 3.5.4: porky pig } else { b = Character.toUpperCase(a); r += b; } } return r; } --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 3.5.4: porky pig How to use it? 3.5.4: porky pig public boolean bracketsMatch(String brackets) { int count = 0; for(char ch : brackets.toCharArray()) { switch(ch) { case '{': count++; break; case '}': if (--count < 0) return false; } 3.5.4: porky pig How to get it? 3.5.4: porky pig } return count == 0; } -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- public String teenTalk(String sentence) { // Your like code like here String a = sentence.replace(" "," like "); return a; } 3.5.4: porky pig How to use it? 3.5.4: porky pig ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- public String teenTalk(String sentence) { // Your like code like here String a = sentence.replace(" "," like "); return a; } ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- public boolean passwordCheck(String password) { 3.5.4: porky pig How to get it for free? 3.5.4: porky pig for(int i = 1; i <= password.length() - 1; i++) { if(password.length() >= 8) { if(Character.isLetterOrDigit(password.charAt(i))) { return true; } return false; } 3.5.4: porky pig How to get it? 3.5.4: porky pig } return false; } -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- public String replaceLetter(String word, char letterToReplace, char replacingLetter) { String a = word.replace(letterToReplace,replacingLetter); return a; } ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 3.5.4: porky pig How to dowload it? 3.5.4: porky pig 3.9: Answers are here: https://quizlet.com/236359458/codehs-methods-questions-flash-cards/ 3.5.4: porky pig