Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me write the pseudocode, create a flowchart with the appropriate shapes, and a Test Plan / Test Case Matrix for the following Java

Please help me write the pseudocode, create a flowchart with the appropriate shapes, and a Test Plan/Test Case Matrix for the following Java code.
"Write a test program that prompts the user to enter a two-dimensional array and displays the location of the largest element in the array.
If there are more than one largest element, find the location with the smallest row index and then the smallest column index."
import java.util.Scanner;
public class Exercise09_13{
public static void main(String[] args){
// Create a Scanner object for user input
Scanner scanner = new Scanner(System.in);
// Prompt the user to enter the number of rows and columns
System.out.print("Enter the number of rows and columns of the array: ");
int rows = scanner.nextInt();
int columns = scanner.nextInt();
// Create a 2D array based on user input
double[][] array = new double[rows][columns];
// Prompt the user to enter the array elements
System.out.println("Enter the array:");
for (int i =0; i < rows; i++){
for (int j =0; j < columns; j++){
array[i][j]= scanner.nextDouble();
}
}
// Call the locateLargest method to get the location of the largest element
int[] location = locateLargest(array);
// Display the location of the largest element
System.out.println("The location of the largest element is at ("+ location[0]+","+ location[1]+")");
}
public static int[] locateLargest(double[][] a){
int[] location = new int[2];
double largest = a[0][0];
// Find the largest element and its location
for (int i =0; i < a.length; i++){
for (int j =0; j < a[i].length; j++){
if (a[i][j]> largest){
largest = a[i][j];
location[0]= i;
location[1]= j;
}
}
}
return location;
}
}

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

Recommended Textbook for

Expert Oracle9i Database Administration

Authors: Sam R. Alapati

1st Edition

1590590228, 978-1590590225

More Books

Students also viewed these Databases questions