Substitution cipher in java | Sololearn: Learn to code for FREE!


Substitution cipher in java

My teacher wants me to do it using only the replace() and charAt() methods, basic loops, and conditional statements. I have given it a shot, but my code doesn't always get it right and frankly, I don't know why. my current attempt:

6/1/2020 9:18:03 PM


3 Answers

New Answer


If you put System.out.println(Klartext); inside the loop it will show you what is happening each iteration. If you run it with "abcdefghijklmnopqrstuvwxyz" as the input you will see an issue


Ok. Now I know the issue but it turns out to be the same issue I have been failing to fix the entire time. You have a character more than one time? The replace method will mess up the encryption. What do you do?


convert Klartext to uppercase