My code creates an array, fills it then compares its value to odd or even and ouputs the response indicated. The output is correct, but I'm not passing the task verifications. Your help is appreciated.
package com.codegym.task.task07.task0706;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
/*
Streets and houses
*/
public class Solution {
public static void main(String[] args) throws Exception {
//write your code here
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
// Read strings from the keyboard
// Read strings from the keyboard
String[] list = new String[15];
for (int i = 0; i < list.length-1; i++)
{
String s = reader.readLine();
list[i] = s;
}
int index = 0;
int even = 0;
int odd = 0;
for(int a = 0; a < list.length-1; a++)
{
if(a % 2 == 0){
even = even + 1;
}else{
odd = odd + 1;
}
}
if(odd > even){
System.out.println("Odd-numbered houses have more residents.");
}else{
System.out.println("Even-numbered houses have more residents.");
}
}
}