Program Konversi Bilangan(Pascal)


Ni sedikit ilmu yang g seberapa silahkan jika ada yang butuh program konversi bilangan menggunakan bahasa pasacal

PROGRAM KONVERSI_BILANGAN;
{AUTHOR: HELA YUDA BUANA, MANAJEMEN INFORMATIKA, GUNADARMA}
USES CRT;
VAR
A,F,Z,W:STRING;

B,D,N,M,I:LONGINT;

C,J,K,E,G,H,X,Y,O:INTEGER;
PILIHAN :BYTE;
BEGIN
CLRSCR;
GOTOXY(10,2);WRITELN (‘ MASUKAN PILIHAN KONVERSI : ‘);
GOTOXY(10,4);WRITELN (‘1.HEX TO DESIMAL’);
GOTOXY(10,6);WRITELN (‘2.OKTAL TO DESIMAL’);
GOTOXY(10,8);WRITELN (‘3.BINER KE DESIMAL’);
GOTOXY(10,10);WRITELN(‘0.SELESAI’);
PILIHAN :=9;
WHILE (PILIHAN <0) OR (PILIHAN>3) DO
BEGIN
GOTOXY(10,20); WRITE (‘MASUKAN PILIHAN KAMU : ‘); READLN(PILIHAN);
END;
CLRSCR;
CASE PILIHAN OF
1:BEGIN
WRITE(‘MASUKAN NILAI HEXADECIMAL= ‘);
READLN(A);
B:=LENGTH(A);M:=0;E:=1;X:=34;Y:=3;
FOR C:= B DOWNTO 1 DO
BEGIN
F:=COPY(A,E,1);
IF (F=’A’) OR (F=’A’) THEN F:=’10’;
IF (F=’B’) OR (F=’B’) THEN F:=’11’;
IF (F=’C’) OR (F=’C’) THEN F:=’12’;
IF (F=’D’) OR (F=’D’) THEN F:=’13’;
IF (F=’E’) OR (F=’E’) THEN F:=’14’;
IF (F=’F’) OR (F=’F’) THEN F:=’15’;
VAL(F,J,K);
H:=C-1;I:=1;
FOR G:=H DOWNTO 1 DO
BEGIN
I:=I*16;
END;
D:=J*I;M:=M+D;E:=E+1;
END;
WRITE(‘UNTUK KONVERSI HEXA TO DECIMAL TEKAN ENTER……. ‘);READLN;
CLRSCR;
WRITE(‘NILAI DECIMAL =’,M);
READLN;
END;
2: BEGIN
WRITE(‘MASUKAN NILAI OKTAL= ‘);
READLN(A);
B:=LENGTH(A);M:=0;E:=1;X:=34;Y:=3;
FOR C:= B DOWNTO 1 DO
BEGIN
F:=COPY(A,E,1);
VAL(F,J,K);
H:=C-1;I:=1;
FOR G:=H DOWNTO 1 DO
BEGIN
I:=I*8;
END;
D:=J*I;M:=M+D;E:=E+1;
END;
WRITE(‘UNTUK KONVERSI OKTAL TO DESIMAL PRESS ENTER……’);READLN;
CLRSCR;
WRITE(‘NILAI DECIMAL =’,M);
READLN;
END;
3: BEGIN
WRITE(‘MASUKAN NILAI BINER= ‘);
READLN(A);
B:=LENGTH(A);M:=0;E:=1;X:=34;Y:=3;
FOR C:= B DOWNTO 1 DO
BEGIN
F:=COPY(A,E,1);
VAL(F,J,K);
H:=C-1;I:=1;
FOR G:=H DOWNTO 1 DO
BEGIN
I:=I*2;
END;
D:=J*I;M:=M+D;E:=E+1;
END;
WRITE(‘UNTUK KONVERSI BINER TO DECIMAL PRESS ENTER…..’);READLN;
CLRSCR;
WRITE(‘NILAI DECIMAL =’,M);
READLN;
END;
END;
END.


Satu Tanggapan

  1. thaxxx….

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: