Caesar Cipher

  • + 1 comment

    few test cases are failing can someone point out the error.

        String temp="";
        for(int i=0;i<=s.length();i++)
        {
            if(s.charAt(i)-'a'>=0 && s.charAt(i)-'z'<26)
            {
                int te=(int)s.charAt(i)-97;
                te=(te+k)%26;
                temp=temp+(char)(te+97);
            } 
            else if(s.charAt(i)-'A'>=0 && s.charAt(i)-'Z'<26)
            {
                int tem=(int)s.charAt(i)-65;
                tem=(tem+k)%26;
                temp=temp+(char)(tem+65);
    
            }
            else
            {
                temp=temp+s.charAt(i);
            }
        }
        return(temp);