Not seeing a Scroll to Top Button? Go to our FAQ page for more info. MEMBUAT MATRIKS DAN TRANFUS | -

My Imaginations

-
Follow Me

MEMBUAT MATRIKS DAN TRANFUS



By  Galeh Fatma Eko Ardiansa     Desember 27, 2013     
program java membuat, membagi matriks dengan jumlah diagonal, mentranfus matriks....
catatan(harus sama baris dan kolomnya...) :)




import java.util.Scanner;
public class Jummat {
static Scanner x= new Scanner(System.in);
    public static void main(String[] args) {
        int b,k,hasil = 0,hasil1=0;
       System.out.print("Masukkan baris : ");b = x.nextInt();
      System.out.print("Masukkan kolom : ");k = x.nextInt();
      if (b == k){
      System.out.println("Matriks 1 : ");
      int mt1[][] = new int[b][k];
      for(int i=0;i<b;i++){
        for(int j=0;j<k;j++){
          System.out.print("Bil baris ke-"+(i+1)+" kolom ke-"+(j+1)+" : ");mt1[i][j] = x.nextInt();           
        }
      }
       System.out.println("Matriks 1 : ");
      for(int i=0;i<b;i++){
        for(int j=0;j<k;j++)
           System.out.print(mt1[i][j] + "  ");
        System.out.println();
      }
      for (int i=0;i<b;i+=1) {
        for(int j=0;j<k;j++)
            if (i==j)
                hasil=hasil+mt1[i][j];
          }
        System.out.println("Hasil Penjumlahan Diagonal matriks adalah : "+hasil);
          System.out.println("");
        System.out.println("Mastriks setelah dibagi diagonal : ");
        for (int i = 0; i < b; i++) {
            for (int j = 0; j < k; j++) {
                System.out.print(String.format("%.2f",(float)mt1[i][j]/hasil) + " ");         
            }
            System.out.println("");
        }
        System.out.println("");
        System.out.println("Matriks setelah ditransfus : ");
        for (int i = 0; i < b; i++) {
            for (int j = 0; j < k; j++) {
                System.out.print(String.format("%.2f",(float) mt1[j][i]/hasil)+" ");
            }
            System.out.println("");
        }
          System.out.println("Terima Kasih :)");
    }
      else
            System.out.println("Maaf Matriks harus persegi...Ex.3x3 or etc");
}
}

selamat mencoba semoga bermanfaat......:)

About Galeh Fatma Eko Ardiansa

If you can dream it, you can do it | Genius is one percent inspiration and ninety-nine percent perspiration | If you don’t make mistakes, you’re not working on hard enough problems | The best and most beautiful things in the world cannot be seen or even touched - they must be felt with the heart | I can't change the direction of the wind, but I can adjust my sails to always reach my destination.

Tidak ada komentar:

Posting Komentar


Formulir Kontak

Nama

Email *

Pesan *

Advertisement

Disqus Shortname