Question: For beginners learning java and remember when writing a code-Dont use each key more than once Write a class that contains an array of int.
For beginners learning java and remember when writing a code-Dont use each key more than once
Write a class that contains an array of int. The array is initially passed to a constructor, and is never modified by the program. The program has the following functions: A constructor that receives an array of int and saves a reference to the array in a private field. A method called euros() that receives a constant, the number of euros per dollar, and returns an array of double. Each element of the array of double contains the value of the corresponding int array converted to euros. A method called mean() that returns the average of all the numbers in the int array as a double. Make sure the average is calculated using double arithmetic, not integer arithmetic. A method called aboveAverage() which returns an int array containing all the items in the original int array that are larger than the value returned by mean(). Call mean exactly once, no more, no less. The returned array must be exactly the correct size, with no extra elements. In other words, figure out how many items are of above average size before allocating the result array. *None* of the methods mentioned above may do *any* I/O. The constructor and euros() each take one argument. mean() and aboveAverage() take no arguments. The number of euros per dollar must be pass to euros() as a names constant. Use the value 0.81 (a dollar is worth 81 euro cents). You may use the following line of code: private static final double eurosPerDollar = 0.81; Use the supplied skeleton code. Your output should look substantially the same as this: Test case 0: Avg 2.5 0.81 1.62 2.43 3.24 Above average: 3 4 Test case 1: Avg 3.0 0.81 1.62 2.43 3.24 4.050000000000001 Above average: 4 5 Test case 2: Avg 5.2 0.0 7.290000000000001 3.24 2.43 4.050000000000001 7.290000000000001 0.81 0.0 4.050000000000001 6.48 0.81 7.290000000000001 7.290000000000001 5.67 6.48 Above average: 9 9 8 9 9 7 8
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
