

String letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char[] letterArray = letters.toCharArray(); //saves each letter to an array
char[] shifted = new char[letters.length()]; //will store the new shifted letters
for(int i = 0; i < letters.length(); i++){
//shift right
if( i != (letters.length()-1) )
shifted[i] = letterArray[i+1];
else shifted[i] = letterArray[0];
}
System.out.println( String.valueOf(shifted) );
import java.util.Scanner;
public class MPGH{
public static Scanner reader = new Scanner(System.in);
public static void main(String []args){
System.out.println("enter a char");
char c = reader.next().CharAt(0);
while(c<'A'||c>'Z'&&c<'a'||c>'z')
{
System.out.println("wrong input, please enter a letter between a and z");
c = reader.next().CharAt(0);
}
if(c>='A'&&c<='Z')
c+=('a'-'A');
if(c=='z')
c='a';
else
c++;
System.out.println(c);
}
}