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
HELP PLS
Angelina_Jolie [31]

Answer:

The correct option is;

B) Metamorphic Rocks

Explanation:

Zoisite, which is also referred to saualpite, is a metamorphic rock which is a hydroxy sorosilicate mineral formed from other types of rocks such as sedimentary, metamorphic and ingenious rocks in the process of their metamorphism under the presence high temperatures and pressures and mineral fluids which are hot

Zoiste is named after Sigmund Zois by Abraham Gottlob Werner in 1805 when Sigmund Zois sent Abraham Gottlob Werner the mineral specimen from Saualpe in 1805

6 0
3 years ago
Give me some examples of fragile structures.
Anvisha [2.4K]

Answer:

i don't know if this help tell me if i am wrong

Explanation:

Gravity is the force that pulls all elements of matter together. Matter refers to things you can physically touch. The more matter there is, the greater the amount of gravity or force. This means that the Earth or other planets have a great deal of pull and that everything on Earth is pulled back to Earth.

Some examples of the force of gravity include:

The force that holds the gases in the sun.

The force that causes a ball you throw in the air to come down again.

The force that causes a car to coast downhill even when you aren't stepping on the gas.

The force that causes a glass you drop to fall to the floor.

3 0
3 years ago
Steam enters a steady-flow adiabatic nozzle with a low inlet velocity (assume ~0 m/s) as a saturated vapor at 6 MPa and expands
Sergio [31]
Yea bro I don’t really know
7 0
3 years ago
You can change lanes during a turn long as there’s no traffic and you driving slowly
Vanyuwa [196]
Your allowed to switch lanes as long as the road is clear and you use signals.
5 0
3 years ago
A microscope illuminator uses a transformer to step down the 120 V AC of the wall outlet to power a 12.0 V,50 W microscope bulb.
Anna35 [415]

Answer:2.88 ohms

Explanation:

R= V^2 / P

12^2/50

144/50

2.88 ohms

5 0
2 years ago
Other questions:
  • The spring has a stiffness k=200 N/m and is unstretched when the 25 kg block is at A. Determine the acceleration of the block wh
    6·1 answer
  • EMB agar is a medium used in the identification and isolation of pathogenic bacteria. It contains digested meat proteins as a so
    10·1 answer
  • When a group of firms chooses to work together to turn a non-monopoly market into a monopoly market by securing formal agreement
    8·1 answer
  • A 625 g basketball and a 58.5 g tennis ball are dropped from a height of d = 1.5 m onto the floor. The coefficient of restitutio
    10·1 answer
  • Consider a vortex filament of strength in the shape of a closed circular loop of radius R. Obtain an expression for the velocity
    10·1 answer
  • An electric power plant uses solid waste for fuel in the production of electricity. The cost Y in dollars per hour to produce el
    10·1 answer
  • Steam in a heating system flows through tubes whose outer diameter is 5 cm and whose walls are maintained at a temperature of 19
    13·1 answer
  • An energy system can be approximated to simply show the interactions with its environment including cold air in and warm air out
    6·1 answer
  • A 50-mm cube of the graphite fiber reinforced polymer matrix composite material is subjected to 125-kN uniformly distributed com
    14·1 answer
  • Some of our modern kitchen cookware is made of ceramic materials. (a) List at least three important characteristics required of
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!