Hello everyone,
can you help me to find the mistake?
I think the program is working good, but unfortunately is not validating the third condition.
Thank you for your help, I really appreciate it :)
Greetings,
Maria :)
package com.codegym.task.task07.task0706;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/*
Streets and houses
*/
public class Solution {
static int num[] = new int [15];
static int oddCount = 0;
static int evenCount = 0;
public static void main (String[] args) throws Exception
{
int num [] = createArray();
oddNumber();
evenNumber();
resultNum();
}
public static int [] createArray() throws IOException
{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
for(int i=0; i<num.length;i++)
{
String snum = reader.readLine();
num [i] = Integer.parseInt(snum);
}
return num;
}
public static int [] oddNumber () throws IOException
{
for(int i= 0;i<num.length; i++)
{
if(num[i] % 2 == 0 || num[i] == 0)
{
oddCount +=1;
}
}
return null;
}
public static int [] evenNumber() throws IOException
{
for(int i= 0;i<num.length; i++)
{
if (num [i] % 2 != 0)
{
evenCount +=1;
}
}
return null;
}
public static int [] resultNum () throws IOException
{
if(oddCount > evenCount)
{
System.out.println("Odd-numbered houses have more residents.");
}
else
{
System.out.println("Even-numbered houses have more residents.");
}
return null;
}
}