Question: I need some assistance with Array methods and python. I cannot use any utilities and the headers have to be exactly as below. Any assistance

I need some assistance with Array methods and python. I cannot use any utilities and the headers have to be exactly as below. Any assistance will be appreciated

Program Requirements Code Organization Write these six methods. You may assume that all test calls will contain valid array references (i.e. non-null references). However, be careful about assuming how many elements are in the arrays. E.g. some arrays may contain only 2, 1, or even 0 elements. Also, be careful about assuming that values are unique, positive, negative, etc. 1. public static void main(String[] args) A main method that creates some test arrays and passes them to your other three methods in various ways for testing. No scanning is required; its easiest to create the arrays manually using initializer lists (look it up).

2. public static int countEvens(int[] a) Use the exact method header above. Return the number of even numbers in the array passed into the method.

3. public static double average(int[] a) Use the exact method header above. Return the average of the numbers in the array passed into the method.

4. public static int maxTwoSum(int[] a) Use the exact method header above. Return the sum of the two largest numbers contained in the array passed into the method. If the array has only one element, return that value. If the array is empty, return 0. You may not call any external methods. Hint: find the location of the max, then, ignoring that location, find the location of the second-max in a similar way

5. public static boolean isSorted(int[] a) Use the exact method header above. Return true if the values in the array passed into the method are sorted in ascending order. Return false if they are not.

6. public static String toString(int[] a) Use the exact method header above. Return a String containing the contents of the array, separated by commas and spaces, with curly braces around the collection. Make sure there is no comma or space after the last item. For example: {1, 2, 3, 4, 5}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!