Kamis, 10 November 2011

Operasi array matriks

import javax.swing.JOptionPane;

/**
 *
 * @author Zed
 */
public class Operasi_Matriks {
    public static void main(String[] args) {

        System.out.println("Operasi Matriks");
        int row = Integer.parseInt(JOptionPane.showInputDialog(null,"Masukkan Jumlah Baris: "));
        int col = Integer.parseInt(JOptionPane.showInputDialog(null,"Masukkan Jumlah Kolom: "));
        double A[][] = new double[row][col];
        double B[][] = new double[row][col];
        double C[][] = new double[row][col];
        double D[][] = new double[row][col];
        int i,j,k;

        System.out.println("\nMatriks A");
        for(i=0;i
            System.out.print("| ");
            for(j=0;j
                A[i][j] = Double.parseDouble(JOptionPane.showInputDialog(null,"Masukkan Matriks A ["+(i+1)+","+(j+1)+"]"));
                System.out.print(" "+A[i][j]+" ");
            }
            System.out.println(" |");
        }

        System.out.println("\nMatriks B");
        for(i=0;i
            System.out.print("| ");
            for(j=0;j
                B[i][j] = Double.parseDouble(JOptionPane.showInputDialog(null,"Masukkan Matriks B ["+(i+1)+","+(j+1)+"]"));
                System.out.print(" "+B[i][j]+" ");
            }
            System.out.println(" |");
        }

        System.out.println("\nPenjumlahan Matriks");
        System.out.println("Matriks A + B =");
        for(i=0;i
            System.out.print(" | ");
            for(j=0;j
                for(k=0;k
                C[i][j] = (A[i][j]+B[i][j]);
                }
            System.out.print(" "+C[i][j]+" ");
            }
            System.out.println(" | ");
        }

        System.out.println("\nPengurangan Matriks");
        System.out.println("Matriks A - B =");
        for(i=0;i
            System.out.print(" | ");
            for(j=0;j
                for(k=0;k
                C[i][j] = (A[i][j]-B[i][j]);
                }
            System.out.print(" "+C[i][j]+" ");
            }
            System.out.println(" | ");
        }

        System.out.println("\nPerkalian Matriks");
        System.out.println("Matriks A x B =");
        for(i=0;i
            System.out.print(" | ");
            for(j=0;j
                for(k=0;k
                D[i][j] = D[i][j]+(A[i][k] * B[k][j]);
                }
            System.out.print(" "+D[i][j]+" ");
            }
            System.out.println(" | ");
        }

    }
}

Kamis, 03 November 2011

looping tugaz

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

package igara;

/**
 *
 * @author ASUS
 */
public class looptugas {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

         for(int a=1; a<=5; a++){
            for (int b=1; b<=a; b++)
                System.out.print(b);
                System.out.print("\n") ;
        // TODO code application logic here
    }
    }
}

looping

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

package igarah;

/**
 *
 * @author ASUS
 */
public class looping {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

         for(int k=1; k<=4; k++){
            for (int j=1; j<=k; j++)
                System.out.print(k);
                System.out.print("\n");
        // TODO code application logic here
    }

    }
}


Senin, 24 Oktober 2011

flowchart dan netbeans bilangan prima


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

package riezal;

import java.util.Scanner;

/**
 *
 * @author TOSHIBA
 */
public class Bilangan_prima {
    public static void main(String[] args) {

       int n;
        System.out.println("\n Masukkan Angka yang akan diuji = ");
        Scanner input = new Scanner (System.in) ;
        n = input.nextInt();

        boolean isPrime = false;
    if (n >= 2) {
        isPrime = true;
       for (int z = 2; z < n; z++) {
        if (n % z== 0) {

                isPrime = false;

            }
        }
    }
    System.out.println("the answer is " + isPrime);
}
}




Minggu, 23 Oktober 2011

flowchart mencari channel TV

flowchart & netbeans persegi panjang






package persegi_panjang;

/**
 *
 * @author TOSHIBA
 */
public class Main {

    /**
     * @param args the command line arguments
     */

 public static void main(String[] args) {
        double p,l,L;

        p = 20;
        l = 15;

        L = p*l;

        System.out.println("Luas persegi panjang" +L);// TODO code application logic here
    }

}


flowchart memperbaiki sepeda motor