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
A cylinder with a frictionless piston contains 0.05 m3 of air at 60kPa. The linear spring holding the piston is in tension. The
AleksAgata [21]

Answer:

18 kJ

Explanation:

Given:

Initial volume of air = 0.05 m³

Initial pressure = 60 kPa

Final volume = 0.2 m³

Final pressure = 180 kPa

Now,

the Work done by air will be calculated as:

Work Done = Average pressure × Change in volume

thus,

Average pressure = \frac{60+180}{2}  = 120 kPa

and,

Change in volume = Final volume - Initial Volume = 0.2 - 0.05 = 0.15 m³

Therefore,

the work done = 120 × 0.15 = 18 kJ

4 0
3 years ago
How do you build a engine best anwser will get marked as brainlist
marysya [2.9K]

Answer:

It is best to soak the new lifters in engine oil overnight in order to build a car engine from scratch, regardless of its length. Ensure all rings of the pistons are installed correctly. You should flip the block over and carefully install the top half of the main rod and bearing parts. Get the block out of your way and flip it over again. By flipping over the block, you’ll see the full effect. Ensure that the lifters are installed correctly.

Explanation:

5 0
2 years ago
A bicycle has tires that are 26 inches in diameter. The while in motion, the tires rotate through 125 complete revolutions. How
Stolb23 [73]

Answer:

850.8480103 feet

Explanation:

First you take the diameter and find the circumference, which is (2)(pi)(r) plug in your r which is 26/2= 13 so 2(13)(pi) and multiply taht by 125 after that take your answer and divide by 12which is 850.8480103

3 0
3 years ago
A 10.2 mm diameter steel circular rod is subjected to a tensile load that reduces its cross- sectional area to 52.7 mm^2. Determ
VMariaS [17]

Answer:

The percentage ductility is 35.5%.

Explanation:

Ductility is the ability of being deform under applied load. Ductility can measure by percentage elongation and percentage reduction in area. Here, percentage reduction in area method is taken to measure the ductility.

Step1

Given:

Diameter of shaft is 10.2 mm.

Final area of the shaft is 52.7 mm².

Calculation:

Step2

Initial area is calculated as follows:

A=\frac{\pi d^{2}}{4}

A=\frac{\pi\times(10.2)^{2}}{4}

A = 81.713 mm².

Step3

Percentage ductility is calculated as follows:

D=\frac{A_{i}-A_{f}}{A_{i}}\times100

D=\frac{81.713-52.7}{81.713}\times100

D = 35.5%.

Thus, the percentage ductility is 35.5%.

5 0
3 years ago
how are the construction steps for bisecting an angle similar to the steps you would have taken to construct and bisect a line s
GREYUIT [131]

Answer:

does the question entail anything else?

Explanation:

5 0
2 years ago
Other questions:
  • A fixed mass of saturated water vapor at 400 kpa is isothermally cooled until it is a saturated liquid. Calculate the amount of
    6·1 answer
  • What is the heights part of Maine?
    5·1 answer
  • You are traveling upstream on a river at dusk. You see a buoy with the number 5 and a flashing green light . What should you do?
    8·1 answer
  • Consider the following grooves, each of width W, that have been machined from a solid block of material. (a) For each case obtai
    8·1 answer
  • How do I calculate the gear ratio​
    6·1 answer
  • According to the eNotes, a program that eliminates sales and promotions in an effort to minimize the bullwhip effect would be ca
    13·1 answer
  • For the system form of the basic laws, the momentum of a system can change as a result of: a. pressure acting on the system. b.
    14·2 answers
  • How would you design a wheelchair for wheelchair-using basketball players? Would you make it more or less massive?
    11·1 answer
  • Discuss in detail the following methods used to redistribute income and wealth in cash grants?​
    5·1 answer
  • Invent five new communication method wired or wireless you think would be practical
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!