Tradutor String Binaro Java
Exames: Tradutor String Binaro Java. Pesquise 862.000+ trabalhos acadêmicosPor: misajr • 20/10/2014 • 326 Palavras (2 Páginas) • 332 Visualizações
package Q1;
import java.util.Scanner;
public class questao1 {
public static void main(String[] args) {
Scanner str = new Scanner(System.in);
System.out.println("###Tradutor de String para Binário ###");
System.out.println("Insira sua entrada em String:");
String frase = str.nextLine();
for (int i = 0; i<frase.length(); i++){
char y = frase.charAt(i);
String x = String.valueOf(frase.charAt(i));
if (x.equals(" ")){
System.out.println("0010 0000");
}
else if(x.equals("a")){
System.out.println("0110 0001");
}
else if (x.equals("b")){
System.out.println("0110 0010");
}
else if (x.equals("c")){
System.out.println("0110 0011");
}
else if (x.equals("d")){
System.out.println("0110 0100");
}
else if (x.equals("e")){
System.out.println("0110 0101");
}
else if (x.equals("f")){
System.out.println("0110 0110");
}
else if (x.equals("g")){
System.out.println("0110 0111");
}
else if (x.equals("h")){
System.out.println("0110 1000");
}
else if (x.equals("i")){
System.out.println("0110 1001");
}
else if (x.equals("j")){
System.out.println("0110 1010");
}
else if (x.equals("k")){
System.out.println("0110 1011");
}
else if (x.equals("l")){
System.out.println("0110 1100");
}
else if (x.equals("m")){
System.out.println("0110 1101");
}
else if (x.equals("n")){
System.out.println("0110 1110");
}
else if (x.equals("o")){
System.out.println("0110 1111");
}
else if (x.equals("p")){
System.out.println("0111 0000");
}
else if (x.equals("q")){
System.out.println("0111 0001");
}
else if (x.equals("r")){
System.out.println("0111 0010");
}
else if (x.equals("s")){
System.out.println("0111 0011");
}
else if (x.equals("t")){
System.out.println("0111 0100");
}
else if (x.equals("u")){
System.out.println("0111 0101");
}
else if (x.equals("v")){
System.out.println("0111 0110");
}
else if (x.equals("x")){
System.out.println("0111 1000");
}
else if (x.equals("w")){
System.out.println("0111 0111");
}
else if (x.equals("y")){
System.out.println("0111 1001");
}
else if (x.equals("z")){
System.out.println("0111 1010 ");
}
else if (x.equals("{")){
System.out.println("0111 1011");
}
else if (x.equals("|")){
System.out.println("0111 1100");
}
else if (x.equals("}")){
System.out.println("0111 1101");
}
else if (x.equals("~")){
...