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

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use 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++) {...

By purchasing this solution you'll be able to access the following files:
Solution.zip.

$13.00
for this solution

or FREE if you
register a new account!

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