Last active
October 17, 2015 21:48
-
-
Save tinkerstudent/9200991d65328f39b355 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.tinkeracademy.ap; | |
| import java.util.Scanner; | |
| public class Main { | |
| public static char[] alphabets = new char[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', | |
| 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', | |
| 'u', 'v', 'w', 'x', 'y', 'z', ' ', '!' | |
| }; | |
| public static char[] reverseAlphabets = new char[] {'\u0250', '\u0071','\u0254', '\u0070','\u01DD', | |
| '\u025F','\u0253', '\u0265','\u0131','\u027E', | |
| '\u029E', '\u006C','\u026F','\u0075','\u006F', | |
| '\u0064','\u0062','\u0279','\u0073','\u0287', | |
| '\u006E','\u028C','\u028D','\u0078','\u028E', | |
| '\u007A',' ', '\u00A1' }; | |
| public static void main(String[] args) { | |
| Scanner s = new Scanner(System.in); | |
| String input = s.nextLine(); | |
| String output = upsideDownText(input); | |
| System.out.println(output); | |
| s.close(); | |
| } | |
| public static String upsideDownText(String input) { | |
| String output = ""; | |
| for (int i = input.length() - 1; i >= 0; i--) { | |
| char in = input.charAt(i); | |
| int index = Main.findCharInArray(in); | |
| char out = reverseAlphabets[index]; | |
| output = output + out; | |
| } | |
| return output; | |
| } | |
| public static int findCharInArray(char in) { | |
| for (int i = 0; i < alphabets.length; i++) { | |
| if (alphabets[i] == in) { | |
| return i; | |
| } | |
| } | |
| return -1; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment