stringToUpperCase: Converts each letter in a string to its uppercase version. For example "Hello!" becomes "HELLO!".stringToLowerCase: The opposite of stringToUpperCase. "Hello!" becomes "hello!".toggleCase: "Hello!" becomes "hELLO!".equalIgnoreCase: Returns whether two strings are equal, ignoring case. For example, returns true for "aBc" and "ABC".isNumber: Returns whether a string consists entirely of digits.getPositionsInAlphabet: Takes a string and returns an integer array with the position of each letter in the alphabet, starting at zero. If a character in the string is not a letter, returns -1. For example:
Your program without methods can look like this:
String input = "Hello world!";
System.out.println("Upper case: " + stringToUpperCase(input));
System.out.println("Lower case: " + stringToLowerCase(input));
String toggled = toggleCase(input);
System.out.println("Toggled: " + toggled);
System.out.println("\"" + input + "\" and \"" + toggled + "\" are " +
"equal (ignoring case): " + equalIgnoreCase(input, toggled));
String numberMaybe = "5801";
System.out.println(numberMaybe + " is a number: " + isNumber(numberMaybe));
String letters = "Abc Xyz";
int[] positionsInAlphabet = getPositionsInAlphabet(letters);
System.out.println("Positions in alphabet of \"" + letters + "\": " +
toString(positionsInAlphabet));
Program output:
Upper case: HELLO WORLD! Lower case: hello world! Toggled: hELLO WORLD! "Hello world!" and "hELLO WORLD!" are equal (ignoring case): True 5801 is a number: True Positions in alphabet of "Abc Xyz": 0, 1, 2, -1, 23, 24, 25
char letter = 'A'; char newLetter = (char)(letter + 1); // newLetter is now 'B'
c represents a digit (0 - 9):
if (c >= 48 && c <= 57)