We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
publicstaticStringcaesarCipher(Strings,intk){// Write your code herek=k%26;StringnewS="";for(chara:s.toCharArray()){if(('z'-a>=0&&a-'a'>=0)){charb=(char)(a+k);if(b-'z'>0){b=(char)(b-26);}newS=newS+b;}elseif(('Z'-a>=0&&a-'A'>=0)){charb=(char)(a+k);if(b-'Z'>0){b=(char)(b-26);}newS=newS+b;}else{newS=newS+a;}}returnnewS;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Caesar Cipher
You are viewing a single comment's thread. Return to all comments →
JAVA solution