Ini juga salah satu tugas Program yang saya Buaaat untuk tugas dengan java prgram ini berguna untuk merubah Kode ASCII ke BINER dan BINER ke Kode ASCII berikut listing programnya
/**
*
* @author Ilham
*/
import java.util.Scanner;
public class KodeAscii {
public static void main(String[] args) throws Exception
{
String temp,ask;
int gol=0,g;
Scanner input = new Scanner (System.in);
do{
System.out.println("-------------------------------------------- ");
System.out.println("| ===========KONVERSI BILANGAN=============| ");
System.out.println("| 1. Konversi bilangan biner ke kode ASCII | ");
System.out.println("| 2. Konversi kode ASCII ke bilangan biner | ");
System.out.println("| 3. exit | ");
System.out.println("---------------------------------------------");
System.out.print("pilihan (1/2/3)= ");
temp = input.nextLine();
try{gol=Integer.parseInt(temp);}
catch (NumberFormatException nfe){
System.out.println("Data Salah !");
System.exit(1);}
switch(gol){
case 1:
String biner;
System.out.print("masukkan bilangan biner = ");
biner=input.nextLine();
int ASCI = Integer.parseInt(biner,2);
char karakter = (char) ASCI;
System.out.println(" | "+biner+" = "+ ASCI +" = "+karakter + (" | "));
break;
case 2:
String str;
System.out.print("masukkan kode ASCII:");
str=input.nextLine();
char[] arrCharStr = str.toCharArray();
System.out.println("==Bilangan biner==");
for (char c : arrCharStr) {
String binr = "0"+Integer.toBinaryString(c);
int ASCII = Integer.parseInt(binr,2);
char karaktr = (char) ASCII;
System.out.println(binr);}
break;
case 3 :
System.out.println("terima kasih");
System.exit(1);
}
System.out.println("");
System.out.println("Ingin Kembali Ke Menu Convert ? ");
System.out.println("1 = YA 0 = TIDAK ");
System.out.print("Masukan Pilihan [1/0] : ");
ask = input.nextLine();
g = Integer.parseInt(ask);
System.out.println("");
}
while (g == 1);
System.out.println(" Terimakasih ");
}
}
Dan Berikut Outputnya
sumber
http://ilhamposts.blogspot.com/2012/11/program-konversi-ascii-ke-biner.html
http://ilfen.blogspot.com/2012/11/program-konversi-kode-ascii-ke-biner.html
1 comments:
http://latihanbasisdata.blogspot.co.id/2016/05/program-convert-ascii-java-gui.html?m=1
Java GUI ASCII Converter
Post a Comment