- 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; } }
2 odpowiedzi
+ 5
It must be 'total==12' or 'total>=12'.
+ 1
OK tashi lemme try