answer.
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
patriot [66]
2 years ago
8

Write a program to declare a matrix A[][] of order (MXN) where ‘M’ is the number of rows and ‘N’ is the

Computers and Technology
1 answer:
Liula [17]2 years ago
4 0

Answer:

import java.io.*;

import java.util.Arrays;

class Main {

   public static void main(String args[])

   throws IOException{

       // Set up keyboard input

       InputStreamReader in = new InputStreamReader(System.in);

       BufferedReader br = new BufferedReader(in);

 

       // Prompt for dimensions MxN of the matrix

       System.out.print("M = ");

       int m = Integer.parseInt(br.readLine());

       System.out.print("N = ");

       int n = Integer.parseInt(br.readLine());

       // Check if input is within bounds, exit if not

       if(m <= 2 || m >= 10 || n <= 2 || n >= 10){

           System.out.println("Matrix size out of range.");

           return;

       }

       // Declare the matrix as two-dimensional int array

       int a[][] = new int[m][n];

 

       // Prompt for values of the matrix elements

       System.out.println("Enter elements of matrix:");

       for(int i = 0; i < m; i++){

           for(int j = 0; j < n; j++){

               a[i][j] = Integer.parseInt(br.readLine());

           }

       }

       // Output the original matrix

       System.out.println("Original Matrix:");

       printMatrix(a);

       // Sort each row

       for(int i = 0; i < m; i++){

         Arrays.sort(a[i]);

       }

       // Print sorted matrix

       System.out.println("Matrix after sorting rows:");

       printMatrix(a);

   }

   // Print the matrix elements separated by tabs

   public static void printMatrix(int[][] a) {

       for(int i = 0; i < a.length; i++){

           for(int j = 0; j < a[i].length; j++)

               System.out.print(a[i][j] + "\t");

           System.out.println();

       }

   }

}

Explanation:

I fixed the mistake in the original code and put comments in to describe each section. The mistake was that the entire matrix was sorted, while only the individual rows needed to be sorted. This even simplifies the program. I also factored out a printMatrix() method because it is used twice.

You might be interested in
Given 3 floating-point numbers. Use a string formatting expression with conversion specifiers to output their average and their
jarptica [38.1K]

Answer:

Following are the program in the Python Programming Language.

#get input from the user

x = float(input())

#get input from the user

y = float(input())

#get input from the user

z = float(input())

#find the average  

average =(x+y+z)/3

#find the product  

product = x*y*z

#print the result in given format

print('\n%d %d'%(average,product))

#print the result in given format

print('%0.2f %0.2f'%(average,product))

Explanation:

<u>Following are the description of the program</u>:

  • We set three variables 'x', 'y', and 'z' that accept float type values from the user.
  • Then, set variable 'average' that store the average of the following values that is given by the user.
  • Set variable 'product' that store the multiplication of the following values that is given by the user.
  • Finally, we print the average and the product in the following format  that is given in the statement.
5 0
2 years ago
9. A __________ gateway sets up two TCP connections, one between itself and a TCP user on an inner host and one between itself a
aev [14]

Answer:

Stateful inspection

Explanation:

Stateful inspection: This is also known as dynamic packet filtering, it is a type firewall technology that monitors the state of active connections and uses this information to determine which network packets will be allowed through the firewall.

3 0
2 years ago
Read 2 more answers
What is the output of 1101 x 10 == 11000 + 10?
Marta_Voda [28]
== is an operator that returns a boolean if both operand are equal.

1101 * 10 is 11010

11000 + 10 is 11010


11010 == 11010

Thus the output would be True.
5 0
2 years ago
An organization’s SOC analyst, through examination of the company’s SIEM, discovers what she believes is Chinese-state sponsored
Vinil7 [7]

Answer: Provided in the explanation segment

Explanation:

Below is a detailed explanation to make this problem more clearer to understand.

(1). We are asked to determine whether the systems have been compromised;

Ans: (YES) From the question given, We can see that the System is compromised. This is so because the plan of communication has different details of scenarios where incidents occur. This communication plan has a well read table of contents that lists specific type of incidents, where each incident has a brief description of the event.

(2). Whether the analyst’s assertion has valid grounds to believe it is Chinese state-sponsored.

Ans: I can say that the analyst uses several different internet protocol address located in so as to conduct its operations, in one instance, a log file recovered  form an open indexed server revealed tham an IP address located is used to administer the command control node that was communicating with the malware.

(3). What other threat intelligence can be generated from this information?

Ans: The threat that can be generated from this include; Custom backdoors, Strategic web compromises, and also Web Server  exploitation.

(4). How would that help shape your assessment?

Ans: This helps in such a way where information is gathered and transferred out of the target network which involve movement of files through multiple systems.

Files also gotten from networks as well as  using tools (archival) to compress and also encrypt data with effectiveness of their data theft.

cheers i hope this helped!!!

3 0
2 years ago
Consider the uc davis policy on reading electronic mail. a research group wants to obtain raw data from a network that carries a
natali 33 [55]

A. discuss the impact of the electronic mail policy on the collection of such data.

8 0
2 years ago
Other questions:
  • ​to add notes or comments, insert a comment tag using the syntax _____.
    5·2 answers
  • A new company starts up but does not have a lot of revenue for the first year. Installing anti-virus software for all the compan
    11·1 answer
  • What two methods can be used to access and modify an existing program that is running on an iot device in cisco packet tracer? (
    6·1 answer
  • 1A network administrator notices that some newly installed Ethernet cabling is carrying corrupt and distorted data signals. The
    5·1 answer
  • What is the statement describing? Agile team continuously adapt to new circumstances and enhance the methods of value delivery
    6·1 answer
  • The area of a square is stored in a double variable named area. write an expression whose value is length of the diagonal of the
    11·1 answer
  • Mike has never used a slide software before, but he needs to create a presentation by the end of the week. what recourse would b
    8·1 answer
  • A _________________________ can use SOAP headers to carry meta information in its messages. A. Web service B. REST Service C. Co
    14·1 answer
  • For example, consider a file with protection mode 644 (octal) contained in a directory with protection mode 730. How might the f
    9·1 answer
  • You need to replace a broken monitor on a desktop system. You decide to replace it with a spare monitor that wasn't being used.
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!