Question: USING JAVA Consider the following methods: StringBuilder has a method append(). If we run: StringBuilder s = new StringBuilder(); s.append(abc); The text in the StringBuilder
USING JAVA
Consider the following methods:
StringBuilder has a method append(). If we run:
StringBuilder s = new StringBuilder();
s.append("abc");
The text in the StringBuilder is now "abc"
Character has static methods toUpperCase() and to LowerCase(), which convert characters to upper or lower case. If we run Character x = Character.toUpperCase('c');, x is 'C'.
Character also has a static isAlphabetic() method, which returns true if a character is an alphabetic character, otherwise returns false.
You will also need String's charAt() method, which returns the character at a given index in the String. For example, "Godzilla".charAt(1) returns 'o'.
Write an application as follows:
- public static String getNonAlpha() takes a String as parameter, builds a StringBuilder consisting of only the nonalphabetic characters in the String, and returns a String based on the StringBuilder (eg, sb.toString())
- public static String getUpper() takes a String, builds a StringBuilder of the upper case versions of all the alphabetic characters in the String, and returns a String based on the StringBuilder.
- main() asks the user for input (using a Scanner) and prints the results of running the input String through each of these methods.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
