Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Describe three other types of visual aids.

Answered: 1 week ago