Test - ArrayLists and Objects


Name _______________________________________________
  1. Write a function that will return the location of the biggest number in an ArrayList of Integer objects.

    public int locationOfBiggest(ArrayList< Integer> a)
    // precondition - List is not empty
  1. Write a function that will delete the biggest number in an ArrayList of Integer objects. You must call the function written in number 1 to get full credit.

    public void deleteBiggest(ArrayList<Integer> a)
    // precondition - List is not empty
  1. There is an ArrayList set up in the following way. There is a name in one location followed by a phone number for that name in the next location.
    Ex.
    0 Joe Smith
    1 336-4533
    2 Tom Jones
    3 456-5644


    Write a function that will receive a last name and then print out the phone number for that person. If the name is not in the list print an appropriate message.

    You should call the function in number 2 to get full credit

    public void printPhone(ArrayList<String> ar, String last)
    // precondition : string in ArrayList contains a first name and a last name - String parameter is only a last name
  1. Write a function that will return the average of all the odd numbers that are in an ArrayList of Integer

    public double getOddAverage(ArrayList<Double> ar)
    // precondition : Arraylist is not empty and contains Double objects