-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathArray21.java
More file actions
24 lines (21 loc) · 588 Bytes
/
Array21.java
File metadata and controls
24 lines (21 loc) · 588 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package array;
/**
* Project Admin -> Husanboy Azamov
* Package Name -> array
* Class Name -> Array21
* Copyright © : 6/23/2022
*/
public class Array21 {
public static void main(String[] args) {
array21(2, 5, new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9});//3+4+5+6 =18/4 =
}
public static void array21(int k, int l, int[] array) {
int sum = 0;
double sol = 0;
for (int i = k; i <= l; i++) {//k=2//
sum += array[i];//sum =array[2]=3;
sol = (double) sum / (l - k + 1);
}
System.out.println(sol);
}
}