Tampilkan postingan dengan label STRUKTUR DATA. Tampilkan semua postingan
Tampilkan postingan dengan label STRUKTUR DATA. Tampilkan semua postingan

Selasa, 23 Juli 2013

Membuat struktur data dengan binary search II


 Berikut source code nya:




/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package binarysearch;

import javax.swing.JOptionPane;

/**
 *
 * @author MACHAAPIEDH
 */
public class BinarySearch {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
      int angka;
        int [] numb = new int [6];
        int key =Integer.parseInt(JOptionPane.showInputDialog("masukkan angka :"));
        System.out.println("key ="+key);
        System.out.println("inputan angka");
        for (int i=0; i<numb.length;i++){
            angka = Integer.parseInt(JOptionPane.showInputDialog("masukkan angka ke-"+(i+1)+"."));
            numb [i]=angka;
            System.out.print(angka+" ");
        }
     

Membuat struktur data dengan binary search


Berikut source code nya:





/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package binarysearch.newpackage;

/**
 *
 * @author MACHAAPIEDH
 */
public class binarySearch {
     public static void main (String [] args){
      int bil []= new int [5];
      bil[0]=20;
      bil[1]=35;
      bil[2]=40;
      bil[3]=60;
      bil[4]=90;
     
      int low, mid, high;
      low = 0;
      high = bil.length-1;
     
      for (int i=0; i<bil.length; i++){
          System.out.print(bil[i]+" ");
      }
      System.out.println("");
     
      int key = 35;
      boolean belumKetemu = true;


Membuat array daftar sebuah toko sepeda


Berikut source code nya:










MAIN:

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package array;
import javax.swing.JOptionPane;
public class Main {

    public static void main(String[] args) {
        dataArray x= new dataArray(3);
        for(int i=0;i<3;i++){
            String merk=JOptionPane.showInputDialog("Masukkan Nama Merk:");
            int harga=Integer.parseInt(JOptionPane.showInputDialog("Masukkan Harga Sepeda:"));
            int jumlah=Integer.parseInt(JOptionPane.showInputDialog("Masukkan Jumlah Sepeda: "));
            x.tambahData(new data(merk,harga,jumlah));
        }
        x.cetak();
    }

}

Entri Populer