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

0

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: https://code.sololearn.com/ciuIeDPHV1zo/#java

6/1/2020 9:18:03 PM

Nico

3 Answers

New Answer

+1

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

0

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?

0

convert Klartext to uppercase