jcreator ( Bilangan desimal kebiner )

jcreator



Bilangan desimal kebiner
===========================================================================
import java.util.NoSuchElementException;
import java.util.Scanner;
public class stackdesimalkebiner {
private class Element {
public Object data;
public Element next;
public Element( Object data, Element next ) {
this.data = data;
this.next = next;
   }
}
private Element top;
public void push( Object data ) {
if( isEmpty( ) ) {
top = new Element( data, null );
else {
top = new Element( data, top );
   }
}
public Object pop( ) throws NoSuchElementException {
if( isEmpty( ) ) {
throw new NoSuchElementException( );
else {
Object data = top.data;
top = top.next;
return data;
  }
}
public Object peek( ) throws NoSuchElementException {
if( isEmpty( ) ) {
throw new NoSuchElementException( );
else {
return top.data;
   }
}
public boolean isEmpty( ) {
return top == null;
}
public static void main(String args[]) {
System.out.println("--Program Konversi Bilangan Desimal ke Biner--");
System.out.println("----------------------------------------------");
Scanner input = new Scanner(System.in);
System.out.print("Masukkan Bilangan Desimal => ");
int bil = input.nextInt();
int c = bil;
stackdesimalkebiner stack = new stackdesimalkebiner();
if (bil == 0) {
System.out.println("0");
}
while (bil != 0) {
int a = bil / 2;
int b = bil % 2;
stack.push(b);
bil = a;
}
System.out.print("Bilangan Biner dari Angka "+c+" = ");
while (!stack.isEmpty()) {
System.out.print(stack.pop());
}
System.out.println(" ");
   }
}



=============================================================================

BAB 3
===========================================================================
class node {
String nama;
node next;
}
public class vivi {
public static void main (String[] args) {
node current=null;
node first= new node(); //create node first
node second= new node(); //create node second
node third= new node(); //create node third
first.nama="VIVI FAKIHAH HARUM";
first.next=second;
second.nama="111210367";
second.next=third;
third.nama="teknik informatika UNISLA";
third.next=null;
current=first; //set pointer to node first
while(current !=null) {
System.out.println(current.nama);
current=current.next;
};
}
}


==================================================================================

2.2
==================================================================
class stack 
{
private  int maxsize; // ukuran array stack
private  long [] stackarray ; // array dengan tipe data long
private  int top; // bagian atas (top) stack
//
public  stack (int s) // konstruktor
{
maxsize = s; // tentukan ukuran array
stackarray = new long [maxsize]; // buat array
top = -1; // saat stack masih kosong
}
//
public  void push (long j) // masukkan data di top
{
stackarray[++top] = j; // naikkan top, masukkan data
}
//
public  long pop () // ambil data dari top
{
return  stackarray [top--]; // akses data, turunkan top
}
//
public  long peek () // melihat data di puncak pada top
{
return  stackarray[top];
}
//
public  boolean isempty () // benar jika stack kosong 
{
return  (top == -1);
}
//
public  boolean isfull () // benar jika stack penuh
{
return  (top == maxsize-1);
}
//
} // akhir dari kelas stack
class aplikasistack
{
public static void main (String[] args)
{
stack stackqu  = new stack (10); // membuat stack baru
stackqu.push(20); // push item ke stack
stackqu.push(40);
stackqu.push(60);
stackqu.push(80);
while (!stackqu.isempty()) // sampai kosong,
{ // hapus item dari stack
Long value= stackqu.pop();
System.out.print(value); // tampilkan
System.out.print("") ;
} // akhir dari perulangan while
System.out.println("") ;
} // akhir dari class main()
} // akhir dari class stackapp
===================================================================================

Nama          : VIVI Fakihah Harum
Nim             : 111210367
Kelompok  : 7
==================================================================
public class stack {
// struktur data 
    private int size ;
    private int top ;
    private int [] data ;
    
// method
    public stack (int n ){
    top = -1;
        size = n;
       data = new int[size];
    }
       
    
    public boolean ispalindrom (){
        return true;   
    }
    public boolean isfull(){
        return top == (size-1)? true : false;
        //if (top ==size -1) return true;
        //else return false;
    }
public  boolean isempty (){
return  top == -1 ?true : false;
//if (top == -1) return true;
//else return false;
}
    public void push (int dt){
        if (! isfull()){
            data[++top]=dt;
        }
    }
    public int pop(){
        int hasil= -999;
        if ( ! isempty()){
            hasil=data[top--];
        }
        return hasil;
    }
   
     public static void main (String[] args) {
   
        stack st =new stack(3);
        st.push(0);
        st.push(6);
        st.push(7);
while (!st.isempty()) {
       System.out.println(st.pop());
    }
    //app stack
    int nilai = 1234;
    stack s= new stack (100);
while (nilai != 0) {
int sisa = nilai % 2;
s.push(sisa);
nilai=nilai/2;
}
while (!s.isempty()) {
System.out.print(s.pop()); 
}
}
}

===========================================================================
import java.util.NoSuchElementException;
import java.util.Scanner;
public class stackdesimalkebiner {
private class Element {
public Object data;
public Element next;
public Element( Object data, Element next ) {
this.data = data;
this.next = next;
   }
}
private Element top;
public void push( Object data ) {
if( isEmpty( ) ) {
top = new Element( data, null );
else {
top = new Element( data, top );
   }
}
public Object pop( ) throws NoSuchElementException {
if( isEmpty( ) ) {
throw new NoSuchElementException( );
else {
Object data = top.data;
top = top.next;
return data;
  }
}
public Object peek( ) throws NoSuchElementException {
if( isEmpty( ) ) {
throw new NoSuchElementException( );
else {
return top.data;
   }
}
public boolean isEmpty( ) {
return top == null;
}
public static void main(String args[]) {
System.out.println("--Program Konversi Bilangan Desimal ke Biner--");
System.out.println("----------------------------------------------");
Scanner input = new Scanner(System.in);
System.out.print("Masukkan Bilangan Desimal => ");
int bil = input.nextInt();
int c = bil;
stackdesimalkebiner stack = new stackdesimalkebiner();
if (bil == 0) {
System.out.println("0");
}
while (bil != 0) {
int a = bil / 2;
int b = bil % 2;
stack.push(b);
bil = a;
}
System.out.print("Bilangan Biner dari Angka "+c+" = ");
while (!stack.isEmpty()) {
System.out.print(stack.pop());
}
System.out.println(" ");
   }
}



=============================================================================

BAB 3
===========================================================================
class node {
String nama;
node next;
}
public class vivi {
public static void main (String[] args) {
node current=null;
node first= new node(); //create node first
node second= new node(); //create node second
node third= new node(); //create node third
first.nama="VIVI FAKIHAH HARUM";
first.next=second;
second.nama="111210367";
second.next=third;
third.nama="teknik informatika UNISLA";
third.next=null;
current=first; //set pointer to node first
while(current !=null) {
System.out.println(current.nama);
current=current.next;
};
}
}


==================================================================================

2.2
==================================================================
class stack 
{
private  int maxsize; // ukuran array stack
private  long [] stackarray ; // array dengan tipe data long
private  int top; // bagian atas (top) stack
//
public  stack (int s) // konstruktor
{
maxsize = s; // tentukan ukuran array
stackarray = new long [maxsize]; // buat array
top = -1; // saat stack masih kosong
}
//
public  void push (long j) // masukkan data di top
{
stackarray[++top] = j; // naikkan top, masukkan data
}
//
public  long pop () // ambil data dari top
{
return  stackarray [top--]; // akses data, turunkan top
}
//
public  long peek () // melihat data di puncak pada top
{
return  stackarray[top];
}
//
public  boolean isempty () // benar jika stack kosong 
{
return  (top == -1);
}
//
public  boolean isfull () // benar jika stack penuh
{
return  (top == maxsize-1);
}
//
} // akhir dari kelas stack
class aplikasistack
{
public static void main (String[] args)
{
stack stackqu  = new stack (10); // membuat stack baru
stackqu.push(20); // push item ke stack
stackqu.push(40);
stackqu.push(60);
stackqu.push(80);
while (!stackqu.isempty()) // sampai kosong,
{ // hapus item dari stack
Long value= stackqu.pop();
System.out.print(value); // tampilkan
System.out.print("") ;
} // akhir dari perulangan while
System.out.println("") ;
} // akhir dari class main()
} // akhir dari class stackapp
===================================================================================

Nama          : VIVI Fakihah Harum
Nim             : 111210367
Kelompok  : 7
==================================================================
public class stack {
// struktur data 
    private int size ;
    private int top ;
    private int [] data ;
    
// method
    public stack (int n ){
    top = -1;
        size = n;
       data = new int[size];
    }
       
    
    public boolean ispalindrom (){
        return true;   
    }
    public boolean isfull(){
        return top == (size-1)? true : false;
        //if (top ==size -1) return true;
        //else return false;
    }
public  boolean isempty (){
return  top == -1 ?true : false;
//if (top == -1) return true;
//else return false;
}
    public void push (int dt){
        if (! isfull()){
            data[++top]=dt;
        }
    }
    public int pop(){
        int hasil= -999;
        if ( ! isempty()){
            hasil=data[top--];
        }
        return hasil;
    }
   
     public static void main (String[] args) {
   
        stack st =new stack(3);
        st.push(0);
        st.push(6);
        st.push(7);
while (!st.isempty()) {
       System.out.println(st.pop());
    }
    //app stack
    int nilai = 1234;
    stack s= new stack (100);
while (nilai != 0) {
int sisa = nilai % 2;
s.push(sisa);
nilai=nilai/2;
}
while (!s.isempty()) {
System.out.print(s.pop()); 
}
}
}

Penulis : Unknown ~ Sebuah blog yang menyediakan berbagai macam informasi

Artikel jcreator ( Bilangan desimal kebiner ) ini dipublish oleh Unknown pada hari Selasa, 24 Juni 2014. Semoga artikel ini dapat bermanfaat.Terimakasih atas kunjungan Anda silahkan tinggalkan komentar.sudah ada 0 komentar: di postingan jcreator ( Bilangan desimal kebiner )
 

0 komentar:

Posting Komentar