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
sasho [114]
3 years ago
15

Write a method named matrixAdd that accepts a pair of two-dimensional arrays of integers as parameters, treats the arrays as 2D

matrices and adds them, returning the result. The sum of two matrices A and B is a matrix C where for every row i and column j, Cij = Aij + Bij. You may assume that the arrays passed as parameters have the same dimensions.
Computers and Technology
1 answer:
Stella [2.4K]3 years ago
7 0

Answer:

The code to this question can be given as follows:

Code:

int matrixAdd(int[][] a, int[][] b) //defining method matrixAdd

{

int c[x][y]=0;//defining variable  

   for(int x = 0; x<a.length; x++)  //loop for add rows

   {

       for(int y= 0; y<a[i].length; y++) //loop for add column

       {

           int c[x][y] = a[x][y] + b[x][y]; //add array elements

       }

   }

  return c[x][y];//return value

}

Explanation:

In the above method definition code, a method "matrixAdd" is defined that contains two integer 2D arrays "a[][] and b[][]" in its parameter, and this function returns the sum of both array.

  • Inside this method, another integer 2D array "c[][]" is defined that contains nothing.
  • To add all array elements the for loop is defined, which uses the array variable "c[][]" to add all array elements and return its value.

You might be interested in
Which of the following statements about light-emitting diodes is correct
kipiarov [429]
The answer is A. LEDs <span>are used as indicators in circuits.</span>
5 0
4 years ago
Assume that name has been declared suitably for storing names (like "Misha", "Emily" and "Sofia"). Assume also that stdin is a v
zaharov [31]

Answer:

// program in java.

import java.util.*;

// class definition

class Main

{// main method of the class

public static void main (String[] args) throws java.lang.Exception

{

   try{

    // object to read input

Scanner scr=new Scanner(System.in);

 // ask to enter name

System.out.print("Enter Your name: ");

 // read name from user

String NAME=scr.nextLine();

// print message

System.out.println("Greetings,"+NAME);

     

   }catch(Exception ex){

       return;}

}

}

Explanation:

Read name from user with the help of scanner object and assign it to variable "NAME".Then print a Greetings message as "Greetings,NAME" where NAME will be  replaced with user's input name.

Output:

Enter Your name: Rachel                                                                                                    

Greetings,Rachel

5 0
3 years ago
Write a method max() which take a generic singly linked list as an argument and returns the maximum element reference in the lis
max2010maxim [7]

Answer:

See explaination

Explanation:

java code:

class DONALD

{

static class Node

{

int data;

Node next;

}

static Node head=null;

static int largestElement(Node head)

{

Int max=Integer.MIN_VALUE;

while(head!=null)

{

if(max<head.data)

max=head.data;

head=head.next;

}

return max;

}

static int smallestElement(Node head)

{

int min=Integer.MAX_VALUE;

while(head!=null)

{

if(min>head.data)

min=head.data;

head=head.next;

}

return min;

}

static void push(int data)

{

Node newNode=new Node();

newNode.data= data;

newNode.next=(head);

(head)=newNode;

}

static void printList(Node head)

{

while(head!=null)

{

System.out.println(head.data + " -> ");

head=head.next;

}

System.out.println("NULL");

}

public static void main(String[] args)

push(15);

push(14);

push(13);

push(22);

push(17);

System.out.println("Linked list is : ");

printList(head);

System.out.println("Maximum element in linked list: ");

System.out.println(largestelement(head));

System.out.print("Maximum element in Linked List: " );

System.out.print(smallestElement(head));

}

}

6 0
3 years ago
How to contact list different from an address book
lisabon 2012 [21]

A contact list is different from an address book because your constancy list consist of people whom you know and choose to communicate with, while the address book gives you a list of the community’s residents phone numbers.



8 0
3 years ago
Read 2 more answers
You are interested in buying a laptop computer. Your list of considerations include the computer's speed in processing data, its
eduard

Answer:

Order Qualifier

Explanation:

An order qualifier is the features of an organization's product or service that is very much necessary to be present for the product or service to even be considered by a buyer. On the other hand, order winners are those features that will win the purchase. From the question, the speed and monitor screen size are the order qualifiers, while the weight and price are the order winners.

5 0
3 years ago
Other questions:
  • Which of the following accurately completes this sentence? The Internet is ____.
    6·2 answers
  • a _____ is a recreation of a thumbnail in a desktop publishing software, also known as a "rough". a. proof b. digital draft c. l
    15·1 answer
  • A technician has been asked to troubleshoot a simple network problem that seems to be caused by software. Which troubleshooting
    7·1 answer
  • Which recovery method usually involves an evasion effort and is dependent on the ip's condition?
    11·1 answer
  • Jed is the database administrator for a mid-sized computer component manufacturer. He is responsible for validating the data mod
    12·1 answer
  • How is an API different from a web application?
    10·1 answer
  • 1
    7·1 answer
  • What is another name for repetition in programming?
    11·1 answer
  • Which of the following is a true statement about parameters in data management? Check all that apply.
    11·1 answer
  • An Accenture healthcare client is interested in implementing an Artificial Intelligence (AI) solution to improve patient care, b
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!