Java array. Please keep it basic and simple. public class PQ06 { /** *
Question:
Java array. Please keep it basic and simple.
public class PQ06
{
/**
* 1. Write the method maxEnd3()
*
* You are given an array of int of any length.
* Your method should figure out which is the
* larger of the first and last elements in the
* array, and then new array of length 3,
* with every element set to that value. Return
* the new array. Do not change your original
* array.
*
* Some examples:
* maxEnd3({1, 2, 3}) returns {3, 3, 3}
* maxEnd3({11, 5, 9}) returns {11, 11, 11}
* maxEnd3({2, 11, 3}) returns {3, 3, 3}.
*
* @param nums an array of int (any length)
* @return an array (length 3) containing the maximum element.
*/
// WRITE THE METHOD maxEnd3() HERE
/**
* 2. Write the method averageOdds()
*
* Start with a positive int array of named nums. Return the
* average of all the odd numbers in the array.
* A number (n) is odd if n % 2 == 1. If there are no
* odd numbers in the array, return -1.
*
* Some examples:
* averageOdds([1, 2, 3]) returns 2.0
* averageOdds([2, 4]) returns -1.0
* averageOdds([2, 3, 4]) returns 3.0
*
* @param nums an array of int (any length)
* @return the average of the odd numbers in the array.
*/
// WRITE THE METHOD averageOdds() HERE
}
Foundations of Financial Management
ISBN: 978-1259024979
10th Canadian edition
Authors: Stanley Block, Geoffrey Hirt, Bartley Danielsen, Doug Short, Michael Perretta