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
How could the location of tests affect the performance of a catapult ?
Luba_88 [7]

Answer:

It could affect how far the projectile travels

Explanation:

Facing Uphill: Moves less far

Downhill: Moves further

3 0
3 years ago
Read 2 more answers
Examine a process whereby air at 300 K, 100 kPa is compressed in a piston/cylinder arrangement to 600 kPa. Assume the process is
professor190 [17]

Answer:

See attachment and explanation.

Explanation:

- The following question can be solved better with the help of a MATLAB program as follows. The code is given in the attachment.

- The plot of the graph is given in attachment.

- The code covers the entire spectrum of the poly-tropic range ( 1.2 - 1.6 ) and 20 steps ( cases ) have been plotted and compared in the attached plot.

3 0
3 years ago
Explain what a margin of safety is in driving as well as how it can help minimize risk.
Yakvenalex [24]

Answer:

A safety margin is the space left between your vehicle and the next to provide room, time and visibility at every instant

Explanation:

A safety margin is defined as an allowance given between your vehicle and the next vehicle in front to provide enough room, visibility and time to move in a safe manner to prevent the occurrence of an accident at anytime the frontal vehicle suddenly stops or slows down

Safety margins help minimize risks in the following way

1) A common knowledge of safety margins, improves predictability among road users, thereby minimizing the risk traffic accidents caused due to late communication

2) The use of safety margins helps minimize the risk due to a change in driving conditions such as when the road becomes more slippery from being covered with fluid that is being wetted

3) Safety margin can help prevent the occurrence of an accident between vehicles due to failure of a car system, such as a punctured tire or failed breaking system

4) Safety margin helps to protect road users from the introduction of obstacles on the main roads such as ongoing road construction, broken down vehicles, road blockage by vehicles involved in an accident etc

5) Safety margin help protect road users from being involved in an accident due to the loss of driving focus of the driver of the frontal vehicle

6 0
3 years ago
Harlin is designing a new car engine that does not create pollution. Which technological design factor is probably the most
kari74 [83]

Answer: environmental impact

Explanation:

From the question, we are informed that Harlin is designing a new car engine that does not create pollution.

The technological design factor which is probably the most important for the design is the impact on the environment.

Pollution has a negative effect on the environment a d doing this shows that emphasis is placed on how the environmental issue of pollution can be tackled.

8 0
3 years ago
I need a thesis statement about Engineers as Leaders.
algol [13]

Answer:

Engineers are a very beneficial contribution in which offers great solutions to national problems.

5 0
3 years ago
Other questions:
  • A 1-lb collar is attached to a spring and slides without friction along a circular rod in a vertical plane. The spring has an un
    6·1 answer
  • Calculate the maximum internal crack length allowable for a 7075-T651 aluminum alloy component that is loaded to a stress one-ha
    15·1 answer
  • What is EL Niño?
    9·1 answer
  • A displacement transducer has the following specifications: Linearity error ± 0.25% reading Drift ± 0.05%/○C reading Sensitivity
    8·1 answer
  • Plz answer all of these questions!
    15·1 answer
  • A railroad runs form city A to city B, a distance of 800km, through mountainous terrain. The present one-way travel time (includ
    13·1 answer
  • Use superpositions find​
    8·1 answer
  • lmfsojdkkfjdsskfsaj;fkljsldfkjlsdkfdjs;dklfjsldkfjflkjfkjfldjsdlfgkljshglksdjfghdskjgsdfkfjghlsdfghsdkjfghlskjdfhglskjdfghkjsfhg
    12·1 answer
  • To ensure that a vehicle crash is inelastic, vehicle safety designers add crumple zones to vehicles. A crumple zone is a part of
    12·1 answer
  • As you have learned, not all motor oils are the same. What are two things that make them different?.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!