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 herechar[]encrypString=newchar[s.length()];if(k>26){intit=k/26;k=k-(it*26);}for(inti=0;i<s.length();i++){intascii=s.charAt(i);System.out.println(ascii);if(ascii>='a'&&ascii<='z'){ascii=s.charAt(i)+k;if(ascii>'z'){ascii=ascii-(26);}}if(ascii>='A'&&ascii<='Z'){ascii=s.charAt(i)+k;if(ascii>'Z'){ascii=ascii-(26);}}encrypString[i]=(char)ascii;}returnnewString(encrypString);}}
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 →