Program that moves characters in n steps to the next character in alphabet based on ASCII code I made a variation on the program that moves the character to the next character. This version moves the characters n steps forward and takes care of white spaces in between. It works but wonder if there is a better way of coding this.
It only works with lowercase alphabet characters.

import java.util.Scanner;
public class NextCharacters{
    public static char nextCharacterInAlphabet(char character , int step)
    {
           char nextChar;           
           int ascii = (int) character;

           if (ascii ==32)  //ascii code for a space is 32
                     /*space stays space that separates the different 
                     strings seperated by the spaces */
                   nextChar = (char) ascii;   
           /*at ascii 104=h remainder goes to zero so i have to add 104, have to add
           104 till ascii=122=z*/
            else if ((ascii +step) % 26&gt;=0 &amp;&amp; (ascii +step) % 26 &lt;=18)
            {
                nextChar = (char) ( ((ascii +step) % 26)+104);
            }
            else
                    nextChar = (char) ( ((ascii +step) % 26)+78);
           /*first character is the 'a' with ascii value 97. Remainder of 97%26 is 19
           so to come up with 97 you have to add 78 to get the value for a.
           The same applies if you increase the number of positions you want the
           chars to move forward, have to this till it reaches ascii =104 where 
           the remainder gets to 0 and have to add 104*/
        return nextChar; 
    }

    public static void main(String[] args) {

        Scanner inputChars = new Scanner( System.in );

        Scanner inputSteps = new Scanner( System.in );

        StringBuilder sb = new StringBuilder();

        System.out.println("Please enter the characters ");
        String characterString = inputChars.nextLine();

        System.out.println("Please enter the number of positions you want each character to move forward");
        int numberOfMovesForward = inputSteps.nextInt();
        for (char c : characterString.toCharArray() )
        {
            sb.append(nextCharacterInAlphabet(c,numberOfMovesForward ));
        }
        System.out.println(sb.toString()) ;

    }

}
You should try to state your problem more clearly: "the program that moves the character to the next character" seem to assume we know some other program you're referring to. If I understand what you're trying to do, this is the problem:

"Given a String, replace each alphabetical character with the character STEP positions after in the alphabet, wrapping around if needed." 

If this is the problem you're trying to solve, here is how I would do it:

public static char nextCharacterInAlphabet(char character , int step) {
  boolean isLower = Character.isLowerCase(character);
  char c = Character.toLowerCase(character);
  if (c &lt; 'a' || c &gt; 'z')
    return character;
  char nextC = (char)((c - 'a' + step) % 26 + 'a');
  return isLower ? nextC : Character.toUpperCase(nextC);
}