Question: in Java, Create a method called sumPositiveBetween that takes as input an array of doubles and two integers. It returns the sum of the doubles

in Java,

Create a method called sumPositiveBetween that takes as input an array of doubles and two integers. It returns the sum of the doubles in the array that are greater than zero and whose indices are between the two input integers. You may assume that the first integer is less than or equal to the second integer and that both input integers are less than or equal to the length of the input array minus 1. If there are no positive values between the two input integers, then this method should return 1.

For example, after the following statements: double[] input = {0, 1, 2, 3, -4, 5, -6, 7, -8, 9};

double res = sumPositiveBetween(input, 3, 9);

res will be 24 because 3 + 5 + 7 + 9 = 24

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!