Hi guys,

I am currently working on a program which gets you to input a cipher, then the message you want to be encoded and it will output an encoded message. Heres the code I have got.
Java Code:
import java.util.Scanner;
public class Cipher
{
   public static void main(String[] args)
    {
        Scanner keyboard = new Scanner(System.in);
        String input;
        String output = "";
        System.out.println("Input Cipher");
        String cipherTemp = keyboard.nextLine(); //getting cipher code
        cipherTemp.replaceAll("\\s",""); //remove whitespace
        
        //removing duplicates in cipher
        Integer cipherTempPosition = 0;
        String cipher = "";
        for (cipherTempPosition = 0; cipherTempPosition < cipherTemp.length(); cipherTempPosition ++)
            {
                char cipherTempChar = cipherTemp.charAt(cipherTempPosition);
                String cipherTempString = "" + cipherTempChar;
                boolean temp = cipher.contains(cipherTempString);
                if (temp == false)
                    {
                        cipher += cipherTemp.charAt(cipherTempPosition);
                    }    
            }
        System.out.println("This is your inputted cipher : " + cipher);
        //adding alphabet to cipher
        String alphabet = "abcdefghijklmnopqrstuvwxyz";
        Integer alphabetPosition = 0;
        for (alphabetPosition = 0;alphabetPosition < alphabet.length();alphabetPosition ++)
            {
                char alphabetTempChar = alphabet.charAt(alphabetPosition);
                String alphabetTempString = "" + alphabetTempChar;
                boolean alphabetTemp = cipher.contains(alphabetTempString);
                if (alphabetTemp == false)
                    {
                        cipher += alphabet.charAt(cipherTempPosition);
                    }
            }
        
        System.out.println("This is your cipher alphabet : " + cipher);
        System.out.println("Input Data");
        input = keyboard.nextLine();
        
        //encoding message
        Integer position = 0;
        for (position = 0; position < alphabet.length(); position ++)
            {
                char cipherChar = cipher.charAt(position);
                String cipherString = "" + cipherChar;
                char alphabetChar = alphabet.charAt(position);
                String alphabetString = "" + alphabetChar;
                input.replace(alphabetString,cipherString);
            }
        System.out.println("This is your encoded message : " + input);
        }
}
The problem is the second for block doesn't output what it should. it tends to just spam the same letter after the cipher word. Also the last for block it doesn't seem to be doing anything at all. If someone could please help me it would be much appreciated. Thanks in advance.