Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a new project. Write a StringMethods class according to the attached spec

ID: 3637387 • Letter: C

Question

Create a new project. Write a StringMethods class according to the attached specification:

Constructor Detail
StringMethods

public StringMethods()

Method Detail
isAllLetters

public static boolean isAllLetters(String s)

Method to determine if a string is all letters

Parameters:
s - the String to test
Returns:
true if all letters; false otherwise. An empty String is not all letters.

reverseName

public static String reverseName(String name)

Method to reverse the parts of a name

Parameters:
name - in firstname lastname format
Returns:
name in lastname,firstname format
Throws:
IllegalArgumentException - if name does not have firstname and lastname.
IllegalArgumentException - if the names are not all letters

Explanation / Answer

// Main Method public class Driver { public static void main(String[] args) { boolean value = StringMethods.isAllLetters("Matthew"); boolean next = StringMethods.isAllLetters("Ma%#$#123"); System.out.println("value: " + value + " next: " + next); String correct = StringMethods.reverseName("Matthew Knudsen"); System.out.println(correct); String wrong = StringMethods.reverseName("Matthew"); } } public class StringMethods { /** * Empty constructor */ public StringMethods() { } /** * * @param s a string * @return true if all letters; false otherwise. An empty string is not all letters */ public static boolean isAllLetters(String s) { boolean value = false; // boolean to return char[] temp = new char[s.length()]; // create a char array to the size of string for(int i = 0; i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote