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 closed system consisting of 4 lb of a gas undergoes a process during which the relation between pressure and volume is pVn 5 c
gayaneshka [121]

Answer:

V1=5<u>ft3</u>

<u>V2=2ft3</u>

n=1.377

Explanation:

PART A:

the volume of each state is obtained by multiplying the mass by the specific volume in each state

V=volume

v=especific volume

m=mass

V=mv

state 1

V1=m.v1

V1=4lb*1.25ft3/lb=5<u>ft3</u>

state 2

V2=m.v2

V2=4lb*0.5ft3/lb=  <u> 2ft3</u>

PART B:

since the PV ^ n is constant we can equal the equations of state 1 and state 2

P1V1^n=P2V2^n

P1/P2=(V2/V1)^n

ln(P1/P2)=n . ln (V2/V1)

n=ln(P1/P2)/ ln (V2/V1)

n=ln(15/53)/ ln (2/5)

n=1.377

3 0
3 years ago
A flywheel made of Grade 30 cast iron (UTS = 217 MPa, UCS = 763 MPa, E = 100 GPa, density = 7100 Kg/m, Poisson's ratio = 0.26) h
hram777 [196]

Answer:

N = 38546.82 rpm

Explanation:

D_{1} = 150 mm

A_{1}= \frac{\pi }{4}\times 150^{2}

              = 17671.45 mm^{2}

D_{2} = 250 mm

A_{2}= \frac{\pi }{4}\times 250^{2}

              = 49087.78 mm^{2}

The centrifugal force acting on the flywheel is fiven by

F = M ( R_{2} - R_{1} ) x w^{2} ------------(1)

Here F = ( -UTS x A_{1} + UCS x A_{2} )

Since density, \rho = \frac{M}{V}

                        \rho = \frac{M}{A\times t}

                        M = \rho \times A\times tM = 7100 \times \frac{\pi }{4}\left ( D_{2}^{2}-D_{1}^{2} \right )\times t

                        M = 7100 \times \frac{\pi }{4}\left ( 250^{2}-150^{2} \right )\times 37

                        M = 8252963901

∴ R_{2} - R_{1} = 50 mm

∴ F = 763\times \frac{\pi }{4}\times 250^{2}-217\times \frac{\pi }{4}\times 150^{2}

  F = 33618968.38 N --------(2)

Now comparing (1) and (2)

33618968.38 = 8252963901\times 50\times \omega ^{2}

∴ ω = 4036.61

We know

\omega = \frac{2\pi N}{60}

4036.61 = \frac{2\pi N}{60}

∴ N = 38546.82 rpm

7 0
3 years ago
When replacing a timing belt, many experts and vehicle manufacturers recommend that all of the following should be replaced exce
lora16 [44]

Answer:

Correct Answer:

A. water pump

Explanation:

<em>Timing belt in a vehicle helps to ensure that crankshaft, pistons and valves operate together in proper sequence.</em> Timing belts are lighter, quieter and more efficient than chains that was previously used in vehicles.

<em>Most car manufacturers recommended that, when replacing timing belt, tension assembly, water pump, camshaft oil seal should also be replaced with it at same time. </em>

7 0
3 years ago
Rosita is planning an investigation to determine how a lifeboat's shape affects its
KiRa [710]
Yes! Is right, just did the work!
3 0
3 years ago
Type the correct answer in the box. Spell all words correctly. Mike is constructing a project in which he uses a motor. How can
tankabanditka [31]
If it is. DC, direct current reverse the polarity of power leads on the motor.

If it is a 3 phase ac alternating current, reverse any of the two of three leads.

Disconnect power before attempting.
6 0
3 years ago
Other questions:
  • Are ocean currents always cold
    10·1 answer
  • A water jet strikes normal to a fixed plate. If diameter of the outlet of the nozzle is 8 cm,and velocity of water at the outlet
    11·1 answer
  • For a bronze alloy, the stress at which plastic deformation begins is 297 MPa and the modulus of elasticity is 113 GPa. (a) What
    7·1 answer
  • Write the following statements as Prolog clauses, in the order given: If it is raining or snowing, then there is precipitation.
    15·1 answer
  • Steel riverts in aluminium drain gutters leak after two years. is it galvanic corrosion? ​
    5·1 answer
  • Based on the following passage, why might the government use the U.S. Army Corps of Engineers to undertake hydroelectric power p
    14·1 answer
  • The cylinder C is being lifted using the cable and pulley system shown.
    8·1 answer
  • A 9 -slug mass hangs by a rope from the ceiling. Using the standard value of gravitational acceleration g = 32.2 fts 2, what is
    12·1 answer
  • Technician A says that a circuit with continuity reads 0 ohms. Technician B says that an open circuit reads 0 ohms. Who is corre
    12·1 answer
  • An American architect whose principles of building included consonance with the landscape was ____________________________.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!