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 solid rod BC has a diameter of 30 mm and is made of an aluminum for which the allowable shearing stress is 25 MPa. Rod AB is
nexus9112 [7]

Answer:

The solid rod BC has a diameter of 30 mm and is made of an aluminum for which the allowable shearing stress is 25 MPa. Rod AB is hollow and has an outer diameter of 25 mm; it is made of a brass for which the allowable shearing stress is 50 MPa.

4 0
2 years ago
What does this work for
Anastaziya [24]

Answer:

it allows your dash board to light up you MPH RPM and all the other numbers on the spadomter

Explanat

8 0
2 years ago
Which is not required when working in a manufacturing facility?
Artyom0805 [142]
Flip flops are not required
5 0
2 years ago
A slender rod AB, of weight W, is attached to blocks A and B, which move freely in the guides shown. The blocks are connected by
gregori [183]

Answer:

(a) T = W/2(1-tanθ)  (b) 39.81°

Explanation:

(a) The equation for tension (T) can be derived by considering the summation of moment in the clockwise direction. Thus:

Summation of moment in clockwise direction is equivalent to zero. Therefore,

T*l*(sinθ) + W*(l/2)*cosθ - T*l*cosθ = 0

T*l*(cosθ - sinθ) = W*(l/2)*cosθ

T = W*cosθ/2(cosθ - sinθ)

Dividing both the numerator and denominator by cosθ, we have:

T = [W*cosθ/cosθ]/2[(cosθ - sinθ)/cosθ] = W/2(1-tanθ)

(b) If T = 3W, then:

3W = W/2(1-tanθ),

Further simplification and rearrangement lead to:

1 - tanθ = 1/6

tanθ = 1 - (1/6) = 5/6

θ = tan^(-1) 5/6 = 39.81°

8 0
2 years ago
An unknown immiscible liquid seeps into the bottom of an open oil tank. Some measurements indicate that the depth of the unknown
barxatty [35]

Answer:

The specific weight of unknown liquid is found to be 15 KN/m³

Explanation:

The total pressure in tank is measured to be 65 KPa in the tank. But, the total pressure will be equal to the sum of pressures due to both oil and unknown liquid.

Total Pressure = Pressure of oil + Pressure of unknown liquid

65 KPa = (Specific Weight of oil)(depth of oil) + (Specific Weight of unknown liquid)(depth of unknown liquid)

65 KN/m² = (8.5 KN/m³)(5 m) + (Specific Weight of Unknown Liquid)(1.5 m)

(Specific Weight of Unknown Liquid)(1.5 m) = 65 KN/m² - 42.5 KN/m²

(Specific Weight of Unknown Liquid) = (22.5 KN/m²)/1.5 m

<u>Specific Weight of Unknown Liquid = 15 KN/m³</u>  

4 0
3 years ago
Other questions:
  • Water is stored in a tank which has vent open to the atmosphere. The water level is 1.0 m below the top the tank and the water i
    7·1 answer
  • Generally natural shape of stone is in shaped as (a)angular (b)irregular (c)cubical cone shape (d)regular
    10·2 answers
  • A square isothermal chip is of width w = 5 mm on a side and is mounted in a substrate such that its side and back surfaces are w
    7·1 answer
  • A rectangular open box, 25 ft by 10 ft in plan and 12 ft deep weighs 40 tons. Sufficient amount of stones is placed in the box a
    13·1 answer
  • Water flows with a velocity of 3 m/s in a rectangular channel 3 m wide at a depth of 3 m. What is the change in depth and in wat
    9·1 answer
  • A 5-mm-thick stainless steel strip (k = 21 W/m•K, rho = 8000 kg/m3, and cp = 570 J/kg•K) is being heat treated as it moves throu
    6·1 answer
  • How can any student outside apply for studying engineering at Cambridge University​
    7·1 answer
  • What’s the answer???
    9·1 answer
  • Overconfidence in more male drivers, particularly those under 25 years old, results in them being involved in crashes.
    14·1 answer
  • What is the purpose of having a ventilation system on board a motorized vessel?.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!