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
The input and output signals of a system is related by the following equation: fraction numerator d squared y over denominator d
Colt1911 [192]

Answer:

Explanation:

The given equation is :

\frac{d^{2}y }{dx^{2} } + sin(3y) \frac{dy}{dt} + y = t\frac{df}{dt} + f

5 0
2 years ago
List six possible valve defects that should be included in the inspection of a used valve?
olchik [2.2K]

Answer:

Valvular stenosis , Valvular prolapse , Regurgitation,

Explanation:

8 0
3 years ago
Match the following items with their correct description.
Lera25 [3.4K]

Answer:

A. Manufacturers rating capacity ↔  3. Must be marked on all jacks; must not be exceeded

B. Block Used to lift and hold heavy loads, allow them for travel ↔ 1. Place the jack head against this

C. Level surface ↔ 4. Place this under the base of the jack when it's necessary to provide a firm foundation

D. Jack ↔ 2. Used to lift and hold heavy loads, allow them for travel

Explanation:

The manufacturers rating for a jack is labelled on all jacks and should be referenced to compare with the load to be lifted so as to ensure a safe and successful lifting.

In order to lift a load, such as a car, it is required to place the jack on a level surface to provide balance during the lifting task

The head of the jack is placed against the block for lifting heavy objects for proper performance

8 0
3 years ago
99 POINTS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
qwelly [4]

Answer:

1. Can you tell me something about yourself?

2. What are you weaknesses?

3. If you would describe yourself in one word?

Explanation: Those questions above 1, 2, and 3 are not harmful to ask your client. Bit the last two 4 and 5 are very harmful, because you don't need to be all up in they business and you don't want to put a lot of pressure on your client.

Hope this helps☝️☝☝

7 0
3 years ago
Read 2 more answers
What is the area enclosed by the cycle area of the Carnot cycle illustrating on a P-V diagram?
Inga [223]

Answer:

The work of the cycle.

Explanation:

The area enclosed by the cycle of the Pressure-Volume diagram of a Carnot engine represents the net work performed by the cycle.

The expansions yield work, and this is represented by the area under the curve all the way to the p=0 line. But the compressions consume work (or add negative work) and this is substracted fro the total work. Therefore the areas under the compressions are eliminated and you are left with only the enclosed area.

7 0
3 years ago
Other questions:
  • What is the difference between absolute and gage pressure?
    11·1 answer
  • Which pendulum will.mobe faster​
    13·1 answer
  • Which type of door consists of thin pieces of wood, glass, or louvers placed within a framed rectangular area?
    7·2 answers
  • Air is compressed in a piston-cylinder device. List three examples of irreversibilities that could occur
    13·1 answer
  • Water, in a 150 in^3 rigid tank, initially has a temperature of 70°F and an enthalpy of 723.5 Btu/lbm. Heat is added until the w
    13·1 answer
  • Practice Problem: True Stress and Strain A cylindrical specimen of a metal alloy 49.9 mm long and 9.72 mm in diameter is stresse
    13·1 answer
  • If a barrel of oil weighs 1.5 kN, calculate the specific weight, density, and specific gravity of the oil. The barrel weighs 110
    7·1 answer
  • A Carnot engine is operated between two heat reservoirs at temperatures of 520 K and 300 K. It receives heat from the 520 K rese
    8·1 answer
  • What is meant by the thickness to chord ratio of an aerofoil?
    12·1 answer
  • What are flip flops and what do they look like
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!