Write a program to accept a string and change the case of each character of the string and display the new string Sample input: Welcome To School Sample output: wELCOME tO School
Answers
Explanation:
import java.io.*;
public class questionFIVE2008
{
public static void main(String args[]) throws IOException
{
int ch;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("ENTER THE STRING ");
String input=br.readLine();
int len=input.length();
int i;
for(i=0; i<len; i++)
{
ch=input.charAt(i);
if(ch>=65 && ch<=90)
{
ch=ch+32;
System.out.print((char)ch);
}
else if(ch>=97 && ch<=122)
{
ch=ch-32;
System.out.print((char)ch);
}
else
{
System.out.print((char)ch);
}
}
}
}