1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Andrei [34K]
3 years ago
11

JAVA Programming.

Computers and Technology
1 answer:
jeka943 years ago
8 0

Answer:

// Java profram to perform Arithmetic operations on square matrices

// Comments are used for explanatory purpose

// Program starts here

import java.util.*;

import java.io;

public class Matrices {

// Multiply Method Here

static void multiply(int mat1[][],int mat2[][], int mulmat[][])

{

int i, j, k;

for (i = 0; i < N; i++)

{

for (j = 0; j < N; j++)

{

mulmat[i][j] = 0;

for (k = 0; k < N; k++)

mulmat[i][j] += mat1[i][k] * mat2[k][j];

}

}

System.out.println("Result matrix" + " is ");

for (i = 0; i < N; i++)

{

for (j = 0; j < N; j++)

System.out.print( mulmat[i][j] + " ");

System.out.println();

}

}

// Subtraction Method here

static void sub(int mat1[][],int mat2[][], int submat[][])

{

for(int i=0;i<N;i++){

for(int j=0;j<N;j++){

addmat[i][j]=mat1[i][j]-mat2[i][j]; //

System.out.print(submat[i][j]+" ");

}

}

// Addition Method here

static void add(int mat1[][],int mat2[][], int addmat[][])

{

for(int i=0;i<N;i++){

for(int j=0;j<N;j++){

addmat[i][j]=mat1[i][j]+mat2[i][j]; //

System.out.print(addmat[i][j]+" ");

}

}

// Main Method Starts here

public static void main (String [] args)

{

Scanner input = new Scanner (System.in);

// Declare type of square matrix

int N;

// input N

lbl: N = input.nextInt();

if(N>=2 && N<=6)

{

int mulmat[][] = new int[N][N] ;

int addmat[][] = new int[N][N] ;

int submat[][] = new int[N][N] ;

// Multiplication

mulmat(mat1, mat2, mulmat);

// Addition

addmat(mat1, mat2, addmat);

// Subtraction

submat(mat1, mat2,submat);

}

else

{

goto lbl;

}

}

You might be interested in
In this section, you will use a stack to implement a program that checks if a string is balanced. Use the skeleton code provided
zimovet [89]

Answer:

Check the explanation

Explanation:

#source code:

import sys

def is_balanced(input_string):

stack = []

for i in input_string:

if(i=="{"):

stack.append("{")

elif(i=="}"):

stack.pop()

if(len(stack)==0):

return True

else:

return False

if __name__ == '__main__':

try:

_input_string = sys.argv[1]

balanced = is_balanced(_input_string)

if balanced:

print("The string {} is balanced".format(_input_string))

else:

print("The string {} is not balanced".format(_input_string))

except:

print("String can't be empty")

Kindly check the attached image below to see the code screenshot and code output.

6 0
3 years ago
Lesson 12: while loops with the farmer. Number 9.
Vikki [24]

Answer:

just repeat the move forward as many times until you get to the hole and fill 1

Explanation:

i think this might work

if it does can i have brainliest

3 0
3 years ago
Read 2 more answers
In the early days of photography, cameras were limited to professional photographers because of the knowledge needed to work the
FinnZ [79.3K]
True they had to be developed in a special way in a dark room with several chemicals. 
3 0
4 years ago
Read 2 more answers
Which type of sentence error, if any, is the above example? 
sammy [17]
I'm gonna say D. No sentence error
3 0
4 years ago
Please solve this,this is a scratch 2.0 question<br><br>The _______ shows the output of a script ?​
rusak2 [61]

Answer:

Console

Explanation:

Not sure exactly what scratch 2.0 is but the console is a separate window that shows the script's outputs and in some cases collect inputs, show error messages or display other info depending on what compiler you used

7 0
3 years ago
Other questions:
  • Which is NOT a way the network operating sys-
    6·1 answer
  • Determine whether the relation represents a function. If it is a​ function, state the domain and range.
    6·1 answer
  • You will be administratively suspended if you have a breath or blood alcohol level of.... or above or refuse to submit to a chem
    12·1 answer
  • Answer the following questions using the five different kinds of parallelism techniques: A - Instruction Level Parallelism B - D
    15·1 answer
  • Which internet resource can you use to publicly describe an adventure trip you recently made?
    6·2 answers
  • I want to know that what is virtually mean can you please help me out
    10·1 answer
  • If you are interested in working for a specific company, what type of job site should you look at for opening?
    15·2 answers
  • HELP WILL GIVE BRAINLIEST
    5·1 answer
  • Please help i have 15 mins
    5·1 answer
  • Technician A says that a camshaft must open and close each valve at exactly the right time relative to piston position. Technici
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!