Array Operations problem.

Posted 05 February 2013 - 12:17 PM

I am working on his project and I am having trouble understanding the actual questions. Here they are...

ArrayOperations:
This class has no field variables. Donít add any!!
Add a static method that performs a sequential search for a given number and returns the subscript.
Add a static method that performs a sort of the array.
Add a static method that performs a binary search of the sorted array and returns the subscript.
Develop the above methods for both int and double data types. Do not develop methods for float and long data types.
Overload each method with a different array data type.
NOTE: Inside of the above methods do not code the size of the array. The array size must be determined by the demo program.
Use the correct data types!!
ArrayOperationsDemo:
Initialize the arrays in code.
Use 5, 2, 4, 3, 1, 6 as the integer array.
Use 8.0, 1.0, 7.0, 2.0, 6.0, 3.0, 5.0, 4.0 as the double array.
Display your initial array.
Your demo class should use each method in the ArrayOperations class at least once.
For each search method, search for a value that is in the array and a value that is not in the array.
Display the result of each method you use.

Re: Array Operations problem.

Posted 06 February 2013 - 03:39 PM

Could anyone check this and tell me if in going in the right direction. Also I was wondering about this portion of the assignment.

ArrayOperationsDemo:
Initialize the arrays in code.
Use 5, 2, 4, 3, 1, 6 as the integer array.
Use 8.0, 1.0, 7.0, 2.0, 6.0, 3.0, 5.0, 4.0 as the double array.
Display your initial array.
Your demo class should use each method in the ArrayOperations class at least once.
For each search method, search for a value that is in the array and a value that is not in the array.
Display the result of each method you use.

How do I run the 2 arrays through the methods correctly. Also in the searching in or out of the arrays?

Re: Array Operations problem.

This is the right idea it "units" existed, but it doesn't. It's not a field - you're not allowed to have any of those. It's not a local variable - you can see it's not declared here. So where does it come from? Solve that, and this will return the correct answer.

Re: Array Operations problem.

Posted 06 February 2013 - 08:25 PM

But how does the method know about it? Your main class is a foreign country. It's possible to make that object visible from other classes - make it public and use a dot reference - but you don't want to do that.

Think about the methods in java.utils.Arrays - how do those methods know about the array you're want them to work on?

Re: Array Operations problem.

Posted 18 February 2013 - 06:18 PM

Thank you pbl !! I've come a little further with that help. Now I'm recieving an error that one of a my variables may not have been initialized at line 109, all that remains is calling each arry through the methods I made and finish this one up. This is what I have now.