Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- public class rot13 {
- public static void main(String[] args) throws IOException {
- BufferedReader myInput = new BufferedReader(new InputStreamReader(System.in));
- System.out.println("Enter a word: ");
- String input = myInput.readLine();
- for (char c : input.toCharArray()) {
- if (Character.isAlphabetic(c)) {
- char lowerChar = (char) (Character.toLowerCase(c) - 97);
- lowerChar += 13;
- lowerChar %= 26;
- lowerChar += 97;
- System.out.print(Character.isUpperCase(c) ? Character.toUpperCase(lowerChar) : lowerChar);
- } else {
- System.out.print(c);
- }
- }
- myInput.close();
- }
- }
Add Comment
Please, Sign In to add comment