-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSumm.java
More file actions
31 lines (28 loc) · 801 Bytes
/
Summ.java
File metadata and controls
31 lines (28 loc) · 801 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
25
26
27
28
29
30
31
import java.util.Scanner;
public class Summ {
int arr[];
Summ() {
arr = new int[5];
Scanner s = new Scanner(System.in);
for (int i = 0; i < arr.length; i++) {
arr[i] = s.nextInt();
}
}
public static void main(String[] args) {
Summ obj = new Summ();
int s=0;
for (int j = 0; j < obj.arr.length; j++) {
s=s+obj.arr[j];
for (int k = j; k < obj.arr.length; k++) {
if (obj.arr[j] == 6){
if(obj.arr[k]==7){
for(int l = j;l<=k;l++){
s=s-obj.arr[l];
}
}
}
}
}
System.out.println(s);
}
}