Guest User

Untitled

a guest
Nov 21st, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. import java.io.*;
  2.  
  3.  
  4. public class rot13 {
  5.  
  6. public static void main(String[] args) throws IOException {
  7. BufferedReader myInput = new BufferedReader(new InputStreamReader(System.in));
  8. System.out.println("Enter a word: ");
  9. String input = myInput.readLine();
  10.  
  11. for (char c : input.toCharArray()) {
  12. if (Character.isAlphabetic(c)) {
  13. char lowerChar = (char) (Character.toLowerCase(c) - 97);
  14. lowerChar += 13;
  15. lowerChar %= 26;
  16. lowerChar += 97;
  17. System.out.print(Character.isUpperCase(c) ? Character.toUpperCase(lowerChar) : lowerChar);
  18. } else {
  19. System.out.print(c);
  20. }
  21. }
  22.  
  23. myInput.close();
  24. }
  25. }
Add Comment
Please, Sign In to add comment