Friday, 19 December 2014

Program for Caeser Cipher




Solution-
//you have to write just the logic part in exam, Header part will be provided by system as You can see in the pic.


int l = input1.length();
char o[] = new char[l];
for (int i = 0; i < l; i++)
 {
char a = input1.charAt(i);
  int b = (int) a;
b = b + 3;

            if (b == 123)//for a
            {
                b = 97;
            }
            if (b == 124)//for b
            {
                b = 95;
            }
            if (b == 125)//for c
            {
                b = 99;
            }
            char m = (char) b;
            o[i] = m;
        }

   output1 = Arrays.toString(o);

No comments:

Post a Comment