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

I need help with the following exercise in Java. Please read instructions to see

ID: 3829448 • Letter: I

Question

I need help with the following exercise in Java. Please read instructions to see what exactly I need done.

Write the following method that returns a new string in which the uppercase letters are changed to lowercase and lowercase letters are changed to uppercase.

public static String swapCase(String s)

In method, swapCase create the variable StringBuilder str = new StringBuilder(s); and use methods in the StringBuilder class to modify str and then return string represented in the StringBuilder object, str. Write a test program that prompts the user to enter a string and invokes this method, and displays the return value from this method. Here is a sample run:

Enter a string: i'M HERE

The new string is: I'm here

Explanation / Answer

Below is the required code:-

Thank you.