Java program to convert uppercase character to lower case and vice versa in a string and append special character in the end
Java program to convert uppercase character to lower case and vice versa in a string and append special character(&^) or any number in the end
for example :
enterd string is
AnUpAm @34 BhaGLANIA
output will be
aNuPaM bHAglania @34
Java Program :
import java.util.*;
public class eval1
{
public static void main(String arr[])
{
Scanner sc=new Scanner(System.in);
String sss=new String();
String ss1=new String();
System.out.println("enter any string");
String s1=sc.nextLine();
int x=s1.length();
System.out.println("length : "+x);
int i,j;
for(i=0;i<x;i++)
{
char chr=s1.charAt(i);
boolean u = Character.isUpperCase(chr);
boolean v = Character.isLowerCase(chr);
if(u==true)
{
char df=Character.toLowerCase(chr);
sss=sss+df;
}
else if(v==true)
{
char df=Character.toUpperCase(chr);
sss=sss+df;
}
else if(s1.charAt(i)==' ')
{
sss=sss+s1.charAt(i);
}
else
{
ss1=ss1+s1.charAt(i);
}
}
sss=sss+' '+ss1;
System.out.println(sss);
}
}
Comments