Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created August 18, 2020 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/a8f9bfb045a43b9687109f304f4b1c7d to your computer and use it in GitHub Desktop.
Save parzibyte/a8f9bfb045a43b9687109f304f4b1c7d to your computer and use it in GitHub Desktop.
public static void main(String[] args) {
String originalText = "parzibyte.me";
System.out.println("Texto original: " + originalText);
String translatedText = textToBinary(originalText);
System.out.println("Convertido a binario es: " + translatedText);
System.out.println("-----------------");
String binaryText = "1110000 1100001 1110010 1111010 1101001 1100010 1111001 1110100 1100101 101110 1101101 1100101";
System.out.println("Binario: " + binaryText);
String translatedBinary = binaryToText(binaryText);
System.out.println("Convertido a texto es: " + translatedBinary);
// También podemos convertir algo que el usuario proporcione
String userText = "";
Scanner sc = new Scanner(System.in);
System.out.println("Ingresa algún texto y yo lo convertiré a binario: ");
userText = sc.nextLine();
translatedText = textToBinary(userText);
System.out.println(translatedText);
System.out.println("Ingresa un texto en binario y lo convertiré a texto en español: ");
userText = sc.nextLine();
translatedBinary = binaryToText(userText);
System.out.println(translatedBinary);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment