I want to write a program which will take a String and add 2 to every character of the String this was quite simple Here is my code. Example:-
String str="ZAP YES";
nstr="BCR AGU" //note Z=B and Y=A
String str=sc.nextLine();
String nstr=""
for(int i=0;i<str.length();i++)
{
char ch=sc.charAt(i);
if(ch!=' ')
{
if(ch=='Z')
ch='B';
else if(ch=='Y')
ch='A';
else
ch=ch+2;
}
nstr=nstr+ch;
}
Now I want to increase every character by n(instead of 2) and this really I could not solve.
I might think of using n%26 ,and use a loop for conditions but I was not able to solve it how to implement that.