Results 1 to 2 of 2
  1. #1
    Jarsss is offline Member
    Join Date
    Nov 2012
    Posts
    3
    Rep Power
    0

    Default 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! =)

  2. #2
    kb9agt is offline Member
    Join Date
    Dec 2012
    Posts
    2
    Rep Power
    0

    Default Re: Need help with Arrays

    Quote Originally Posted by Jarsss View Post
    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! =)
    A good way to start is to make your files and then just put your assignment description at the top in comments. Then go search the web. Start at The Java™ Tutorials or just search for java arrays.

Similar Threads

  1. Copying Single Arrays to 2-D Arrays
    By jmscarlet9 in forum New To Java
    Replies: 7
    Last Post: 04-03-2012, 12:17 AM
  2. Casting Enum Type arrays to object type arrays
    By nmvictor in forum Advanced Java
    Replies: 4
    Last Post: 02-17-2012, 01:49 PM
  3. arrays and multidimensional arrays
    By belfast09 in forum New To Java
    Replies: 5
    Last Post: 06-14-2011, 02:28 PM
  4. store array of arrays in array of arrays
    By joost_m in forum New To Java
    Replies: 4
    Last Post: 04-19-2010, 11:32 AM
  5. Arrays.sort... why sorting all arrays in class?
    By innspiron in forum New To Java
    Replies: 6
    Last Post: 03-23-2010, 02:40 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •