You are viewing a single comment's thread. Return to all comments →
//Answer in java import java.io.; import java.math.; import java.security.; import java.text.; import java.util.; import java.util.concurrent.; import java.util.regex.*;
public class cipher {
private static final Scanner scanner = new Scanner(System.in); public static void main(String[] args) { int n = scanner.nextInt(); scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?"); String s = scanner.nextLine(); int k = scanner.nextInt(); scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?"); scanner.close(); for(int i=0;i<s.length();i++) { int ch=s.charAt(i); if(ch>=97&&ch<=122) { ch+=k; if(ch<=122) { System.out.print((char)ch); } else{ while(ch>122) { ch=ch-122; ch=96+ch; } System.out.print((char)ch); } } else if(ch>=65&&ch<=90) { ch+=k; if(ch<=90) { System.out.print((char)ch); } else{ while(ch>90) { ch=ch-90; ch=64+ch; } System.out.print((char)ch); } } else{ System.out.print((char)ch); } } }
}
Seems like cookies are disabled on this browser, please enable them to open this website
Caesar Cipher: Encryption
You are viewing a single comment's thread. Return to all comments →
//Answer in java import java.io.; import java.math.; import java.security.; import java.text.; import java.util.; import java.util.concurrent.; import java.util.regex.*;
public class cipher {
}