LOGIKA PROGRAM
Program disini dibuat
menggunakan bahasa pemrograman Java, program ini menggunakan 2 class,
class pertama untuk Frame atau untuk menampilkan hasil dari konversi
dan class kedua digunakan untuk mengconvert inputan menjadi konversi
basis bilangan.
Pada listing diatas
merupakan listing dari tombol konversi, jadi jika user mengklik
tombol tsb listing diatas akan dieksekusi, dimana maksud dari listing
tsb terdapat perintah percabangan untuk mengolah inputan, pada
kondisi pertama jika variabel PILIH1 = 0 atau user memilih DEC pada
inputan, maka nilai inputan akan disimpan dalam variabel tempInput
dan yang nantinya akan dikonversi diclass yang kedua, kondisi kedua
jika variabel PILIH1 = 1 atau user memilih HEX pada inputan, maka
nilai inputan akan disimpan dalam variabel tempInput dan yang
nantinya akan dikonversi diclass Komponen atau class yang kedua.
Begitu pun seterusnya.
Lalu pada perintah
percabangan kedua berfungsi untuk mengolah inputan atau mengambil
nilai yang sudah dikonversi sebelumnya diclass yang kedua atau class
Komponen, kondisi pertama jika Pilih2 = 0 atau user memilih DEC pada
outputan, maka variabel tempInput akan diubah menjadi tipe data
string, dan disimpan dalam variabel hasilnya. Kondisi kedua jika
Pilih2 = 1 atau user memilih HEX pada outputan, maka variabel
tempInput akan diubah tipe datanya dari hex ke string, lalu nilai
akan disimpan dalam variabel hasilnya, begitu pun pada kondisi
ketiga.
Terakhir variabel
hasilnya akan dicetak dikolom Output.
Listing diatas merupakan
class kedua atau class Komponen yang digunakan untuk mengkonversi
inputan dan kemudian akan dikembalikan sesuai perintah panggilan pada
percabangan kedua, angka 16, 10, 8 merupakan radix atau basis pada
suatu bilangan.
Terakhir adalah listing
dari tombol HAPUS, maksud dari listing tsb adalah mengembalikan nilai
index Pilih1 dan Pilih2 menjadi 0 atau mengembalikan Pilhan menjadi
DEC dikedua pilihan, dan mengkosongkan pada kolom Input dan Output.
Algoritma Program
1. User akan memasukkan
data pada kolom pertama atau kolom Input kemudian user akan memilih
basis bilangan antara DEC, HEX, atau OCT.
2. Dan inputan tadi
akan diproses untuk dikonversi di Class kedua.
3. Lalu user akan
memilih hasil outputnya antara DEC, HEX atau OCT
4. Jika sudah memilih
kemudian user akan mengklik tombol “KONVERSI”
5. Hasil akan muncul
pada kolom kedua atau kolom Output.
6. Tombol hapus
berfungsi untuk menhapus kolom-kolom Input dan Output dan
mengembalikan pilihan basis bilangan seperti semula yaitu ke DEC.
OUTPUT
DEC – HEX
DEC – OCT
HEX – DEC
HEX – OCT
OCT – DEC