/* Define a class to accept a string, and print the characters with the uppercase and lowercase reversed, but all the other
* characters should remain the same as before.
* Example: Input : WelCoMe_2022
* Output : wELcOmE_2022
*/
import java.util.*;
class QUESTION_5
{
public static void main(String[]args)
{
Scanner sc=new Scanner(System.in);
String str;
System.out.println("Enter a String :");
str=sc.nextLine();
int l=str.length();
for(int i=0;i<l;i++)
{
char ch=str.charAt(i);
if(Character.isLowerCase(ch))
System.out.print(Character.toUpperCase(ch));
else if(Character.isUpperCase(ch))
System.out.print(Character.toLowerCase(ch));
else
System.out.print(ch);
}
}
}
No comments:
Post a Comment
any problem in any program comment:-