Results 1 to 2 of 2
Thread: Need help with Arrays
- 12-01-2012, 08:50 PM #1Member
- Join Date
- Nov 2012
- Rep Power
Need help with Arrays
I have 3 programs that i need to write. All including arrays.
First one is:
Complete the method named averagePrice, in the program below, named Prices.java, so that it accepts an array of prices as a parameter, and returns the average price. You may assume all prices are double values.
Second one is:
Complete the method named middleValue, in the program below, named ArrayOps.java, so that it accepts an array of integer values as a parameter, and returns the value in the middle of the array.
For instance, if an array contains five elements, then the third element would be the middle element to be returned. However, if the array contains six elements, both the third and fourth values could be considered to be the middle elements. In this case, only return the first middle value, namely, the third element of the array.
Third one is:
Complete the method, named findValue, in the class named ArrayOps.java. There are two parameters to this method: the first is an integer array and the second is a integer value.
This method should use a linear search to try to find an instance of the integer value parameter within the array. If the value is in the array, the method returns the subscript of the array where the value was found. If the value is not in the array, the value of the length of the array is returned (as that is a higher value than any of the array subscripts).
My issue that im having is where do i even start. I could probably to this without methods, but once methods get involved i become lost. Also how do i make the array without being given an array size and/or prompting the user for the array size. If anyone can direct me in the correct direction or if you have done these programs please share your knowledge! =)
- 12-02-2012, 12:51 AM #2Member
- Join Date
- Dec 2012
- Rep Power
Re: Need help with Arrays
The Java™ Tutorials or just search for java arrays.
- By jmscarlet9 in forum New To JavaReplies: 7Last Post: 04-03-2012, 12:17 AM
- By nmvictor in forum Advanced JavaReplies: 4Last Post: 02-17-2012, 01:49 PM
- By belfast09 in forum New To JavaReplies: 5Last Post: 06-14-2011, 02:28 PM
- By joost_m in forum New To JavaReplies: 4Last Post: 04-19-2010, 11:32 AM
- By innspiron in forum New To JavaReplies: 6Last Post: 03-23-2010, 02:40 AM