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
lianna [129]
1 year ago
14

Q4 a.

Engineering
1 answer:
dedylja [7]1 year ago
7 0

The Java program that accepts a matrix of M × N order and then interchanges diagonals of the matrix is given below:

<h3>Steps:  </h3>
  • 1. We can only interchange diagonals for a square matrix.
  • 2. Therefore, we would have to create a square matrix of size [M × M].
  • 3. We would check whether the matrix is a square matrix or not. If the matrix is square then follow step 3 else terminate the program.
  • 4. Apply logic for interchange diagonal of the matrix some logic is given below.

<h3>Java Code</h3>

//  Java Program to Accept a Matrix of Order M x N &

//  Interchange the Diagonals

import java.util.Scanner;

public class InterchangeDiagonals {

   public static void main(String[] args)

   {

       // declare variable

       int m, n, i, j, temp;

       // create a object of scanner class

       Scanner sc = new Scanner(System.in);

       System.out.print("Enter number of rows ");

       // take number of rows

       m = sc.nextInt();

       System.out.print("Enter number of columns ");

       // take number of columns

       n = sc.nextInt();

       // declare a mxn order array

       int a[][] = new int[m][n];

       // if block it's execute when m is equals to n

       if (m == n) {

           System.out.println(

               "Enter all the values of matrix ");

           // take the matrix inputs

           for (i = 0; i < m; i++) {

               for (j = 0; j < n; j++) {

                   a[i][j] = sc.nextInt();

               }

           }

           System.out.println("original Matrix:");

           // print the original matrix

           for (i = 0; i < m; i++) {

               for (j = 0; j < n; j++) {

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

               }

               System.out.println("");

           }

          // perform interchange

           for (j = 0; j < m; j++) {

               temp = a[j][j];

               a[j][j] = a[j][n - 1 - j];

               a[j][n - 1 - j] = temp;

           }

           System.out.println(

               " after interchanging diagonals of matrix ");

           // print interchanged matrix

           for (i = 0; i < m; i++) {

               for (j = 0; j < n; j++) {

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

               }

               System.out.println("");

           }

       }

       // else block it's only execute when m is not equals

       // to n

       else {

           System.out.println("Rows not equal to columns");

       }

   }

}

Read more about java programming here:

brainly.com/question/18554491

#SPJ1

You might be interested in
Lagest organs of the human body
aliya0001 [1]

Answer:

skin is the largest organ

3 0
3 years ago
Read 2 more answers
Wireless technology has made communicating
emmainna [20.7K]

Answer:

Taking as a basis of calculation 100 mol of gas leaving the conversion reactor, draw andcompletely label a flowchart of this process. Then calculate the moles of fresh methanol feed,formaldehyde product solution, recycled methanol, and absorber off-gas, the kg of steamgenerated in the waste-heat boiler, and the kg of cooling water fed to the heat exchangerbetween the waste-heat boiler and the absorber. Finally, calculate the heat (kJ) that must beremoved in the distillation column overhead condenser, assuming that methanol enters as asaturated vapor at 1 atm and leaves as a saturated liquid at the same pressure.

1

SEE ANSWER

Explanation:

6 0
3 years ago
Show that for a linearly separable dataset, the maximum likelihood solution for the logisitic regression model is obtained by fi
KATRIN_1 [288]

Answer:

Answer for the question:

"Show that for a linearly separable dataset, the maximum likelihood solution for the logisitic regression model is obtained by finding a weight vector w whose decision boundary wx. "

is explained in the attachment.

Explanation:

8 0
3 years ago
True or False: The differential lock in an AWD-equipped vehicle can be used at any time.
Bingel [31]

the answer would be false

7 0
3 years ago
Read 2 more answers
Which rigid motion maps the solid-line figure onto the dotted-line figure?
Agata [3.3K]
I would love to answer but unfortunately there is no picture.
5 0
3 years ago
Other questions:
  • 1. Create a class called Name that represents a person's name. The class should have fields named firstName representing the per
    8·2 answers
  • Whenever you are around construction sites, you should A speed up so you get through it quicker and avoid falling rocks B maneuv
    10·1 answer
  • What happens to a commercial airline at cruising altitude if the pilot does not touch the throttles?
    12·1 answer
  • Consider the experiment of Problem 1.27, in which a frictionless puck is sliding straight across a rotating turntable through th
    10·1 answer
  • A rectangular open channel is 20 ft wide and has a bed slope of 0.007. Manning's roughness coefficient n is 0.03. It is in unifo
    10·1 answer
  • Introduction for site visit​
    13·1 answer
  • How can any student outside apply for studying engineering at Cambridge University​
    7·1 answer
  • your friend's parents are worried about going over their budget for th month. Which expense would you suggest is NOT a need?
    9·1 answer
  • Recall the steps of the engineering design process. Compare and contrast the
    9·1 answer
  • Find the mean deviation of the set of numbers<br> (a) 12, 6, 7, 3, 15, 10, 18,5
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!