Hi all.
I need help with my program. Beginning
java student here.
I am supposed to create an array by prompting the user for the number of rows and columns.
Then the user is to enter the rows and columns.
At this point, a method is invoked that is to locate the largest element and then return the position of the element in the array.
As far as I can tell, my main method is correct, but I'm having trouble with the other method.
We are to create an array that stores the location of the current largest element.
Could anyone offer any help? After much trial and error, this is the version that shows no red flags in Eclipse, but it's result is this as the location of the largest element "[I@14318bb". I have a feeling this is wrong LOL.
This is the pseudocode we are to follow from my instructor:
// import package for reading keyboard input
// program name
public class LargestElementLocator
{
// program start
public static void main (
String [] args)
{
// prompt user for number of rows and columns
// create an empty array based on user input
// for each row
// promt user for row elements
// store elements in appropriate row
// end for
// invoke locateLargest method and store its return values
// display the row an columns of the largest element
// in array based on the values returend by method
}
// locateLargest method
public static int [] locateLargest(double [][] a)
{
// initialize variable largest to 0
// create array b of size 2 to store row and colum of
// largest element in a
// for each row of array a
// for each column of array a
// if element in array a is larger than largest
// store row and column of array a in array b
// end if
// end for
// end for
// return array b
}
}
My apologies for the long post.
Thank you for any advice in advance.