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
You are about to perform PMCS on your M1114? What resource should you use for the procedures and instructions for performing PMC
aniked [119]

The resources and instructions that should be used for the procedures of performing PMCS are:

  1. Operator's manuals
  2. Safety cautions and warnings.
  3. Fording kit
  4. Heating and cooling systems.

<h3>What is PMCS?</h3>

PMCS is an acronym for preventive maintenance checks and services and it can be defined as the maintenance, checks, and services that are typically performed before, during, and after the use of any type of military equipment such as:

  • M1114
  • M1151
  • M1123

Basically, the resources and instructions that should be used for the procedures of performing PMCS are:

  1. Operator's manuals
  2. Safety cautions and warnings.
  3. Fording kit
  4. Heating and cooling systems.

Read more on PMCS here: brainly.com/question/15720250

#SPJ1

4 0
1 year ago
Design a decimal arithmetic unit with two selection variables, V1, and Vo, and two BCD digits, A and B. The unit should have fou
Bingel [31]
Ucsaaaaauxx627384772938282’cc ed un e uff ridicolizzarla +golfista
4 0
3 years ago
An 1,840 W toaster, a 1,420 W electric frying pan, and a 70 W lamp are plugged into the same outlet in a 15 A, 120 V circuit. (T
Viktor [21]

Answer:

A)

Current drawn by toaster = 15.33 A

Current drawn by electric frying pan = 11.83 A

Current drawn by lamp = 0.58 A

B)

The fuse will definitely blow up since the current drawn by three devices (27.74 A) is way higher than 15 A fuse rating.

Explanation:

There are three devices plugged into the same outlet.

Toaster = 1840 W

Electric frying pan = 1420 W

Lamp = 70 W

Since the three devices are connected in parallel therefore, the voltage across them will be same but the current drawn by each will be different.

A) What current is drawn by each device?

The current flowing through the device is given by

I = P/V

Where P is the power and V is the voltage.

Current drawn by toaster:

I = 1840/120

I = 15.33 A

Current drawn by electric frying pan:

I = 1420/120

I = 11.83 A

Current drawn by lamp:

I = 70/120

I = 0.58 A

B) Will this combination blow the 15-A fuse?

The total current drawn by all three devices is

Total current = 15.33 + 11.83 + 0.58

Total current = 27.74 A

Therefore, the fuse will definitely blow up since the current drawn by three devices (27.74 A) is way higher than 15 A fuse rating.

5 0
3 years ago
Alternating current lesson 4 exam
zloy xaker [14]
Huh? whats the question?
6 0
2 years ago
Air enters a compressor at a pressure of 74.7 kPa and 287 K and leaves at 622 kPa and 579 K. The air flow rate is 50 kg/s. Calcu
vampirchik [111]

Answer:

attached below

Explanation:

7 0
2 years ago
Other questions:
  • What is the maximum number of 12-2 with ground nonmetallic-sheathed cables permitted in an 18-cubic-inch device box if two singl
    11·2 answers
  • An inductor (L = 400 mH), a capacitor (C = 4.43 µF), and a resistor (R = 500 Ω) are connected in series. A 44.0-Hz AC generator
    11·1 answer
  • In remote areas, your gps devices may lose reception. It’s a good idea to have a
    7·2 answers
  • A tank has two rooms separated by a membrane. Room A has 1 kg of air and a volume of 0.5 m3; room B has 0.75 m3 of air with dens
    15·1 answer
  • The status of which of these determines the sequence in which output devices, such as solenoid values and motor contactors, are
    15·1 answer
  • 12. A structural component is fabricated from an alloy that has a plane strain fracture toughness of It has been determined that
    11·1 answer
  • Which of the following sentences uses the word malleable correctly?
    7·2 answers
  • Which statement describes a possible limitation on a experimental design? A. Collecting samples to analyze is expensive B. The e
    6·2 answers
  • Why is there an Engineering Process?
    15·2 answers
  • A(n) _____ is an apparatus that changes alternating current (AC) to direct current (DC)
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!