Getting correct output, still shows not working. What to do?
package com.codegym.task.task07.task0706;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/*
Streets and houses
1. Create an array of 15 integers.
2. Populate it with values from the keyboard.
3. Let the array index represent the house number. The array value at
-a particular index represents the number of people living in the corresponding house.
Houses with odd numbers are located on one side of the street.
-Those with even numbers are on the other side. Find out which side
-of the street has more people living on it.
4. Display the following message: "Odd-numbered houses have more residents."
-or "Even-numbered houses have more residents."
Note:
the house at index 0 is considered even.
*/
public class Solution {
static int sum_even = 0, sum_odd = 0;
public static void main(String[] args) throws Exception {
//write your code here
int[] num = new int[15];
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
for(int i = 0; i < 15; i++) {
num[i] = Integer.parseInt(reader.readLine());
if(i == 0) {
if(num[i] == 0)
continue;
else if(num[i] % 2 == 0)
sum_even += num[i];
else
sum_odd += num[i];
}
else if(num[i] == 0)
sum_even += num[i];
else if(num[i] % 2 == 0)
sum_even += num[i];
else
sum_odd += num[i];
}
//System.out.println(sum_even);
//System.out.println(sum_odd);
if(sum_even > sum_odd)
System.out.println("Even-numbered houses have more residents.");
else
System.out.println("Odd-numbered houses have more residents.");
}
}