How To Create Computer Shift Button In Java - Java Program Example

Write A Java Program To Convert Small Alphabet  To Capital Alphabet And Capital Alphabet To Small Alphabet. When Compile  This Program Compiler Take Input As  Santense Or Any Text Alphabet By User . Compiler Show OutPut After Compile Program.

Program Code


package com.androidpro.in;


import
java.io.BufferedReader;
import
java.io.IOException;
import
java.io.InputStreamReader;
import
java.util.Scanner;

public class
Main {

   
public static void main(String args[])throws IOException

    {

       
int i,l;char ch;String str1="";

       
InputStreamReader reader=new InputStreamReader(System.in);

       
BufferedReader br=new BufferedReader(reader);

       
String str=br.readLine();

       
l=str.length();

        for
(i=0;i<l;i++)

        {

            ch=str.charAt(i)
;

            if
(ch>='A'&&ch<='Z')

            {

                ch+=
32;

           
}

           
else if(ch>='a'&&ch<='z')

            {

                ch-=
32;

           
}

            str1=str1+ch
;

       
}

        System.
out.println("You Typed Text =\t"+str);

       
System.out.println("After Convert  =\t"+str1);

   
}


}

 


 

 

 

Output 1

ABCDEFGHIJKLMNOPQRSTUVWXYZ

You Typed Text = ABCDEFGHIJKLMNOPQRSTUVWXYZ

After Convert  = abcdefghijklmnopqrstuvwxyz

Output 2

abcdefghijklmnopqrstuvwxyz

You Typed Text = abcdefghijklmnopqrstuvwxyz

After Convert  = ABCDEFGHIJKLMNOPQRSTUVWXYZ

Post a Comment

0 Comments