Draw a flowchart for this code package main; import java.util.Scanner; public class main { public static int[]
Question:
Draw a flowchart for this code
package main;
import java.util.Scanner; public class main { public static int[] locateSmallest(double array[][]) { double minimumElement = array[0][0]; int arr[] = new int[2]; int i, j;
for (i = 0; i < array.length; i++) { for (j = 0; j < array.length; j++) { if (minimumElement > array[i][j]) { minimumElement = array[i][j]; arr[0] = i; arr[1] = j;
} } } return arr;
} public static void main(String[] args) { int row, column, i, j; Scanner s = new Scanner(System.in); System.out.print("Enter the number of rows: ");
row = s.nextInt(); System.out.print("Enter the number of columns: ");
column = s.nextInt();
double array[][] = new double[row][column];
System.out.println("Enter the array: "); System.out.print("Row 1 : "); for (i = 0; i < row; i++) {
for (j = 0; j < column; j++) { array[i][j] = s.nextDouble(); } System.out.print("Row " + (i + 2) + " : "); }
System.out.println("Elements of the array are: "); for (i = 0; i < row; i++) { for (j = 0; j < column; j++)
System.out.print(array[i][j] + " ");
System.out.println();
} int arr[] = locateSmallest(array); i = arr[0]; j = arr[1]; System.out.println(); System.out.println("The location of the smallest element is at (" + i + ", " + j + ")");
}
}
Starting Out With Java From Control Structures Through Data Structures
ISBN: 9780133957051
6th Edition
Authors: Tony Gaddis