Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 11

LAPORAN AKHIR

Mata praktikum Kelas Praktikum ke Tanggal Materi NPM Nama Ketua Asisten Paraf Asisten Jumlah Lembar : : : : : : : : : : Lembar AP 1 & Matematika Informatika 1IA25 3 19-Nov-2011 Relasi dan Matriks 58411123 Astri Wiguna

LABORATORIUM INFORAMATIKA UNIVERSITAS GUNADARMA 2011

Listing Program Matriks


import javax.swing.*; public class matriks { public static void main (String [] args) { int ordo = 3; int A[][]= new int [ordo][ordo]; int B[][]= new int [ordo][ordo]; int C[][]= new int [ordo][ordo]; for (int baris=0; baris<ordo; baris++) { for (int kolom=0; kolom<ordo; kolom++) { A[baris][kolom] = Integer.parseInt(JOptionPane.showInputDialog("Masukkan Matriks A ["+(baris)+"] ["+(kolom)+"]")); B[baris][kolom] = Integer.parseInt(JOptionPane.showInputDialog("Masukkan Matriks B ["+(baris)+"] ["+(kolom)+"]")); C[baris][kolom] = Integer.parseInt(JOptionPane.showInputDialog("Masukkan Matriks C ["+(baris)+"] ["+(kolom)+"]")); } } System.out.println("\n"+"Matriks A"); for (int baris=0; baris<ordo ;baris++ ) { for (int kolom=0; kolom<ordo; kolom++) { System.out.print ("| "+A[baris][kolom]+" "); } System.out.println ("| ");

} System.out.println("\n"+"Matriks B"); for (int baris=0; baris<ordo; baris++) { for (int kolom=0; kolom<ordo; kolom++ ) { System.out.print ("| "+B[baris][kolom]+" "); } System.out.println ("| "); } System.out.println("\n"+"Matriks C"); for (int baris=0; baris<ordo; baris++) { for (int kolom=0; kolom<ordo; kolom++ ) { System.out.print ("| "+C[baris][kolom]+" "); } System.out.println ("| "); } } }

Output Program

Listing Program Relasi


//nama file : relasi.java import javax.swing.*; public class relasi { public static void main(String[] args) { int A[] = new int [10]; int B[] = new int [10]; int jumlaha = Integer.parseInt (JOptionPane.showInputDialog ("Masukkan Banyak Matriks A")); for ( int x = 0 ; x < jumlaha ; x++ ) { A[x] = Integer.parseInt(JOptionPane.showInputDialog ("Elemen A Ke - " + (x+1))); } int jumlahb = Integer.parseInt (JOptionPane.showInputDialog ("Masukkan Banyak Matriks B")); for ( int y = 0 ; y < jumlahb ; y++ ) { B[y] = Integer.parseInt(JOptionPane.showInputDialog ("Elemen B Ke - " + (y+1))); } System.out.print ("Himpunan A = { " ); for ( int x = 0 ; x < jumlaha ; x++ ) { System.out.print ( A[ x ] ); if (x!=jumlaha-1) System.out.print (" , "); } System.out.println (" } "); System.out.print ("Himpunan B = { " ); for ( int y = 0 ; y < jumlahb ; y++ )

{ System.out.print ( B[y]); if (y!=jumlahb-1) System.out.print (" , "); } System.out.println (" } "); { System.out.print ("Relasi Yang Memungkinkan = { " ); } for ( int x = 0 ; x < jumlaha ; x++ ) { for ( int y = 0 ; y < jumlahb ; y++ ) { System.out.print (" ( " + A[x] + " , " + B[y] + " ) "); System.out.print (" , "); } } System.out.println(" } "); } }

Output Program Relasi

You might also like