QuestionQuestion

Question 1: Write a program to read an integer N (2 <= N <= 30) from an input filename “input5_01.txt” and then:

a. Write a function to create an N x N matrix with random integers from the range [10, 99]. Output that matrix to the output filename “output5_01.txt”.

b. Find the maximum number of each row and each column of the matrix created in part a). Output those number to the same file “output5_01.txt”.

c. Find all primes in the matrix and output those to same file “output5_01.txt”.
Note: Do not print out duplicate primes.

Example:
Input
File “input5_01.txt”
5

Output
File “output4_01_1.txt”

+ Part a)
13 56 95 11 16
12 23 25 77 83
19 99 21 86 46
34 66 29 67 42
29 20 50 71 83

+ Part b)
Max rows: 95 83 99 67 83
Max cols: 34 99 95 86 83

+ Part c)
13 11 23 83 19 29 67 29 71

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

public class question1 {

    /**
    * @param args the command line arguments
    */
    public static void main(String[] args) {
       try (               
            FileWriter fw = new FileWriter("output4_01_1.txt")) {
            int n = readfile("input5_01.txt");
            int [][] matrix = partA(n, fw);
            partB(matrix, n, fw);
            partC(matrix, n, fw);
            fw.close();
       } catch (IOException ex) {            
       }
    }
   
    /**
    * part c
    * @param matrix
    * @param n
    * @param fw
    * @throws IOException
    */
    public static void partC(int [][] matrix, int n, FileWriter fw) throws IOException {
      
       fw.write( System.lineSeparator() + "+ Part c)" + System.lineSeparator());
       for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {...
$13.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats