11. Write a program in Java to accept a String from the user. Pass the String to a function
Change (String str) which displays the first character of each word after changing the
case (lower to upper and vice versa).
Sample Input : Delhi public school
Answers
Answer:
Here, our task is to replace all the lower-case characters in the string to upper-case and upper-case characters to lower-case.
For this purpose, we need to traverse the string and check for each character. If the character is a lower-case character, make it upper-case by using the language-specific built-in method or add 32 to the lower-case character in C to change the ASCII value of the character.
Explanation:
Here, our task is to replace all the lower-case characters in the string to upper-case and upper-case characters to lower-case.
For this purpose, we need to traverse the string and check for each character. If the character is a lower-case character, make it upper-case by using the language-specific built-in method or add 32 to the lower-case character in C to change the ASCII value of the character.