I clearly have the comparison between number of even and odd residents and the proper output.
Any feedback is welcome!
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 boolean debug = true;
public static void main(String[] args) throws Exception {
//write your code here
int[] residence = new int[15];
int oddNum = 0;
int evenNum = 0;
BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
for(int houseNum =0;houseNum<residence.length;houseNum++){
residence[houseNum]= Integer.parseInt(r.readLine());
int x = residence[houseNum];
if(x % 2 == 0){
evenNum = evenNum+x;
}
else{
oddNum = oddNum+x;
}
}
if(debug) System.out.println(evenNum);
if(debug) System.out.println(oddNum);
if(evenNum>oddNum){
System.out.println("Even-numbered houses have more residents.");
}
else {
System.out.println("Odd-numbered houses have more residents.");
}
}
}