Posts which you will also like.

Sunday, September 5, 2010

Program To Change the Case(Lower to Upper)

import javax.swing.JOptionPane;
class toupper
{   
    private String str1,str2;
    public void tuper()
    {    //str="az";
        str2="";
        str1=JOptionPane.showInputDialog(null,"Enter a string:");
        int len=str1.length();
        char ch[]=new char[len];
        ch=str1.toCharArray();
        for(int i=0;i
        {
            if(ch[i]>=97 ||ch[i]<=122)
            ch[i]-=32;
            str2+=ch[i];
                 }
               JOptionPane.showMessageDialog(null,"Original String:"+str1+"\n After Changing case:"+str2);
    }
    public static void main(String []args)
    {
        toupper t=new toupper();
        t.tuper();
       
    }
}

No comments:

Post a Comment

Your comment may wait for moderation....

DMCA.com Protected by Copyscape Online Plagiarism Tool