import java.io.*;
class Change
{
String str,newstr;
int len;
Change()
{
str="";newstr="";len=0;
}
void inputword()throws IOException
{
BufferedReader x=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Input a word");
str=x.readLine();
str=str.trim();
len=str.length();
}
char caseconvert(char ch)
{
int i=ch,j=0;
if(i>=65&&i<=90)
j=i+32;
else if(i>=97&&i<=122)
j=i-32;
else j=i;
return (char)j;
}
void recursionchange(int a)
{
if(a==len)
return;
else
{
char ch=caseconvert(str.charAt(a));
newstr=newstr+ch;
++a;
recursionchange(a);
}
}
void display()
{
System.out.println("Original String="+str);
System.out.println("After converting case="+newstr);
}
public static void main (String[] args)throws IOException
{
Change call=new Change();
call.inputword();
int p=0;
call.recursionchange(p);
call.display();
}
}
class Change
{
String str,newstr;
int len;
Change()
{
str="";newstr="";len=0;
}
void inputword()throws IOException
{
BufferedReader x=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Input a word");
str=x.readLine();
str=str.trim();
len=str.length();
}
char caseconvert(char ch)
{
int i=ch,j=0;
if(i>=65&&i<=90)
j=i+32;
else if(i>=97&&i<=122)
j=i-32;
else j=i;
return (char)j;
}
void recursionchange(int a)
{
if(a==len)
return;
else
{
char ch=caseconvert(str.charAt(a));
newstr=newstr+ch;
++a;
recursionchange(a);
}
}
void display()
{
System.out.println("Original String="+str);
System.out.println("After converting case="+newstr);
}
public static void main (String[] args)throws IOException
{
Change call=new Change();
call.inputword();
int p=0;
call.recursionchange(p);
call.display();
}
}
No comments:
Post a Comment