Declare and code a method sumEven that will receive:
• An array of double values as the only parameter.
The method will calculate the sum of the values located in even
indexes.
You should only code the missing method in the following program. As
execution examples you can read the method execution in 5 and 6. The
output for each of those lines of code should be as the explained in
their corresponding comments.
In Code
1
public class UTSA1083FA20_QC2{
2
public static void main(String[] args){
3
double[] arr = {1.9, 2.4, 3.1, 2.7, 1.7, 2.6, 3.4, 2.1, 1.5, 2.0};
4
double[] arr2 = {4.2, 1.2, 2.1, 3.3, 2.6, 1.1, 4.5, 3.8, 2.5, 1.0};
5
System.out.println(sumEven(arr)); // Will print 11.6
6
System.out.println(sumEven(arr)); // Will print 15.9
7
}
8
// Your code should go here
9
}