JAVA_CODINGS Telegram 77
57. Matrix Subtraction.

import java.util.Scanner;

class Matrix_Subtraction {

Scanner scan;
int matrix1[][], matrix2[][], sub[][];
int row, column;

void create() {

scan = new Scanner(System.in);

System.out.println("Matrix Subtraction");

// First Matrix Creation..
System.out.println("\nEnter number of rows & columns");
row = Integer.parseInt(scan.nextLine());
column = Integer.parseInt(scan.nextLine());

matrix1 = new int[row][column];
matrix2 = new int[row][column];
sub = new int[row][column];

System.out.println("Enter the data for first matrix :");

for(int i=0; i &lt row; i++) {

for(int j=0; j &lt column; j++) {

matrix1[i][j] = scan.nextInt();
}
}

// Second Matrix Creation..
System.out.println("Enter the data for second matrix :");

for(int i=0; i &lt row; i++) {

for(int j=0; j &lt column; j++) {

matrix2[i][j] = scan.nextInt();
}
}
}

void display() {

System.out.println("\nThe First Matrix is :");

for(int i=0; i &lt row; i++) {

for(int j=0; j &lt column; j++) {

System.out.print("\t" + matrix1[i][j]);
}
System.out.println();
}

System.out.println("\n\nThe Second Matrix is :");

for(int i=0; i &lt row; i++) {

for(int j=0; j &lt column; j++) {

System.out.print("\t" + matrix2[i][j]);
}
System.out.println();
}
}

void sub() {

for(int i=0; i &lt row; i++) {

for(int j=0; j &lt column; j++) {

sub[i][j] = matrix1[i][j] - matrix2[i][j];
}
}

System.out.println("\n\nThe Subtraction is :");

for(int i=0; i &lt row; i++) {

for(int j=0; j &lt column; j++) {

System.out.print("\t" + sub[i][j]);
}
System.out.println();
}
}
}

class MatrixSubtractionExample {

public static void main(String args[]) {

Matrix_Subtraction obj = new Matrix_Subtraction();

obj.create();
obj.display();
obj.sub();
}
}

@java_codings



tgoop.com/java_codings/77
Create:
Last Update:

57. Matrix Subtraction.

import java.util.Scanner;

class Matrix_Subtraction {

Scanner scan;
int matrix1[][], matrix2[][], sub[][];
int row, column;

void create() {

scan = new Scanner(System.in);

System.out.println("Matrix Subtraction");

// First Matrix Creation..
System.out.println("\nEnter number of rows & columns");
row = Integer.parseInt(scan.nextLine());
column = Integer.parseInt(scan.nextLine());

matrix1 = new int[row][column];
matrix2 = new int[row][column];
sub = new int[row][column];

System.out.println("Enter the data for first matrix :");

for(int i=0; i &lt row; i++) {

for(int j=0; j &lt column; j++) {

matrix1[i][j] = scan.nextInt();
}
}

// Second Matrix Creation..
System.out.println("Enter the data for second matrix :");

for(int i=0; i &lt row; i++) {

for(int j=0; j &lt column; j++) {

matrix2[i][j] = scan.nextInt();
}
}
}

void display() {

System.out.println("\nThe First Matrix is :");

for(int i=0; i &lt row; i++) {

for(int j=0; j &lt column; j++) {

System.out.print("\t" + matrix1[i][j]);
}
System.out.println();
}

System.out.println("\n\nThe Second Matrix is :");

for(int i=0; i &lt row; i++) {

for(int j=0; j &lt column; j++) {

System.out.print("\t" + matrix2[i][j]);
}
System.out.println();
}
}

void sub() {

for(int i=0; i &lt row; i++) {

for(int j=0; j &lt column; j++) {

sub[i][j] = matrix1[i][j] - matrix2[i][j];
}
}

System.out.println("\n\nThe Subtraction is :");

for(int i=0; i &lt row; i++) {

for(int j=0; j &lt column; j++) {

System.out.print("\t" + sub[i][j]);
}
System.out.println();
}
}
}

class MatrixSubtractionExample {

public static void main(String args[]) {

Matrix_Subtraction obj = new Matrix_Subtraction();

obj.create();
obj.display();
obj.sub();
}
}

@java_codings

BY Advance Java πŸ‘¨β€πŸ’»


Share with your friend now:
tgoop.com/java_codings/77

View MORE
Open in Telegram


Telegram News

Date: |

How to create a business channel on Telegram? (Tutorial) Users are more open to new information on workdays rather than weekends. Ng was convicted in April for conspiracy to incite a riot, public nuisance, arson, criminal damage, manufacturing of explosives, administering poison and wounding with intent to do grievous bodily harm between October 2019 and June 2020. On June 7, Perekopsky met with Brazilian President Jair Bolsonaro, an avid user of the platform. According to the firm's VP, the main subject of the meeting was "freedom of expression." The Standard Channel
from us


Telegram Advance Java πŸ‘¨β€πŸ’»
FROM American