Question: import javax.swing.*; import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class TwoDimArray { public static void main(String[] args) { TwoDimArray twoDimArray = new TwoDimArray(); System.out.println(Maximum value:

import javax.swing.*; import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner;

public class TwoDimArray { public static void main(String[] args) { TwoDimArray twoDimArray = new TwoDimArray(); System.out.println("Maximum value: " + twoDimArray.getArrayMaxValue()); System.out.println("Minimum value: " + twoDimArray.getArrayMinValue()); }

private int array[][]; public TwoDimArray() { loadArray(); } public void loadArray() { String fileName = ""; try { fileName = JOptionPane.showInputDialog("Enter file name: "); } catch (Exception e) { JOptionPane.showMessageDialog(null, "can not open " + fileName + " to read"); return; } try { Scanner scan = new Scanner(new File(fileName)); int rows, columns; rows = scan.nextInt(); columns = scan.nextInt(); array = new int[rows][columns]; for(int i = 0; i < rows; ++i) { for(int j = 0; j < columns; ++j) { array[i][j] = scan.nextInt(); } } scan.close(); } catch (FileNotFoundException e) { JOptionPane.showMessageDialog(null, "can not open " + fileName + " to read"); } }

public int getArrayMaxValue() { int maxValue = Integer.MIN_VALUE; for(int i = 0; i < array.length; ++i) { for(int j = 0; j < array.length; ++j) { if(array[i][j] > maxValue) { maxValue = array[i][j]; } } } return maxValue; }

public int getArrayMinValue() { int minValue = Integer.MAX_VALUE; for(int i = 0; i < array.length; ++i) { for(int j = 0; j < array.length; ++j) { if(array[i][j] < minValue) { minValue = array[i][j]; } } } return minValue; }

}

Q.Add javadoc block in the program and create a UML for the program

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!