We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 32535f6 commit d5f6dd4Copy full SHA for d5f6dd4
src/main/java/CaesarShift.java
@@ -13,7 +13,7 @@ public String encrypt(String msg){
13
//loop through the character array
14
for(Character character : upCasedArrs ){
15
int index = ALPHABET.indexOf(character.toString());//get the character rank in the alphabet
16
- int encryptedCharIndex = (index+key)%26;//shift the character using the key and get the new characters rank in the alphabet
+ int encryptedCharIndex = Math.floorMod((index+key),26);//shift the character using the key and get the new characters rank in the alphabet
17
encryptedChars.add(ALPHABET.charAt(encryptedCharIndex));//get the character from the alphabet rank and add it to the char array
18
encryptedMsg = encryptedChars.toString().replaceAll("\\[|\\]|\\s","").replaceAll(",","");//convert and cleanup the char array to a string
19
}
0 commit comments