/**ICSE BOARD QUESTION 2008
* Write a program to input a string and print out the text
* with the uppercase and lowercase letters reversed ,
* but all other characters should remain the
* same as before.
* EXAMPLE: INPUT: WelComE TO School
* OUTPUT: wELcOMe to sCHOOL
*
*/
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);
}
}
}
}
OUTPUT:
ENTER THE STRING
WelComE TO School
wELcOMe to sCHOOL
THIS IS IT
ReplyDeleteTHIS IS IT
ReplyDeleteThis prgm does not work on orginal java compiler
ReplyDeleteU must be crazy...ha ha ;)
DeleteCan u please use scanner class and do this program?
ReplyDeleteIKR
DeleteThis program is correct
ReplyDeleteany here for computer board project 2021 xD ?
ReplyDelete