Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- /**
- *
- * @author rich
- */
- public class Metrik {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- int a[][] = new int[3][3];
- int b[][] = new int[3][3];
- int hasil[][] = new int[3][3];
- Scanner tampung=new Scanner(System.in);
- for(int putarcol=0;putarcol<a[0].length;putarcol++){
- for(int putarrow=0;putarrow<a[0].length;putarrow++){
- System.out.print("Masukan nilai array A"+putarcol+"."+putarrow+": ");
- int nilai=tampung.nextInt();
- a[putarcol][putarrow]=nilai;
- }
- }
- System.out.println("");
- for(int putarcolom=0;putarcolom<b[0].length;putarcolom++){
- for(int putarbaris=0;putarbaris<b[0].length;putarbaris++){
- System.out.print("Masukan nilai array B"+putarcolom+"."+putarbaris+": ");
- int nilai=tampung.nextInt();
- b[putarcolom][putarbaris]=nilai;
- }
- }
- for (int colom = 0; colom < a[0].length; colom++) {
- for (int row = 0; row < b[0].length; row++) {
- hasil[colom][row] = (a[colom][0] * b[0][row]) + (a[colom][1] * b[1][row]) + (a[colom][2] * b[2][row]);
- }
- }
- for (int o = 0; o < a[0].length; o++) {
- System.out.print("| ");
- for (int p = 0; p < a[0].length; p++) {
- System.out.print(a[o][p] + " ");
- }
- System.out.print("|");
- if (o == 1) {
- System.out.print("X");
- }else{
- System.out.print(" ");}
- System.out.print("| ");
- for (int q = 0; q < b[0].length; q++) {
- System.out.print(b[o][q]+" ");
- }
- System.out.print("|");
- if (o == 1) {
- System.out.print("=");
- }else{
- System.out.print(" ");}
- System.out.print("| ");
- for (int r = 0; r < hasil[0].length; r++) {
- System.out.print(+hasil[o][r] + " ");
- }
- System.out.print("|");
- System.out.println(" ");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement