- 1

I've got a code that returns 1 if the array has a number divisible by two and has a sum of 12 else return 0.....help plz

public class Program { public static void main(String[] args) { int[]arr={2,4,6}; int total =0; int result = 0; for (int i=0;i<arr.length;i++){ total = (total += arr[i]); if (arr[i]%2==0 && total=12) { int result = 1 ; break ; } } int result; } }

27th Feb 2017, 5:47 PM
Ricardo Chitagu
Ricardo Chitagu - avatar
2 Antworten
+ 5
It must be 'total==12' or 'total>=12'.
27th Feb 2017, 6:44 PM
Tashi N
Tashi N - avatar
+ 1
OK tashi lemme try
27th Feb 2017, 7:39 PM
Ricardo Chitagu
Ricardo Chitagu - avatar