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

1st Jun 2020, 9:18 PM
Nico
3 Antworten
+ 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
1st Jun 2020, 9:56 PM
JME
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?
1st Jun 2020, 10:32 PM
Nico
0
convert Klartext to uppercase
1st Jun 2020, 11:59 PM
zemiak