package com.codegym.task.task07.task0706;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/*
Streets and houses
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int arr[] = new int[15];
int even = 0;
int odd = 0;
for (int i = 0; i < arr.length; i++) {
arr[i] = Integer.parseInt(reader.readLine());
if(i % 2 == 0)
{even= even + arr[i];}
else
{ odd = odd + arr[i];}
}
System.out.println(even);
System.out.println(odd);
if(odd > even) {
System.out.println("Odd-numbered houses have more residents.");}
else
{System.out.println("Even-numbered houses have more residents.");}
}
}
package com.codegym.task.task07.task0706;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/*
Streets and houses
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int arr[] = new int[15];
int even = 0;
int odd = 0;
for (int i = 0; i < arr.length; i++) {
arr[i] = Integer.parseInt(reader.readLine());
if(i % 2 == 0)
{even= even + arr[i];}
else
{ odd = odd + arr[i];}
}
System.out.println(even);
System.out.println(odd);
if(odd > even) {
System.out.println("Odd-numbered houses have more residents.");}
else
{System.out.println("Even-numbered houses have more residents.");}
}
}
//1. The program must create an array of 15 integers.
//2. The program should read numbers for the array from the keyboard.
//3. The program should display "Odd-numbered houses have more residents.
//" if the sum of odd array elements is greater than the sum of even ones.
//4. The program should display "Even-numbered houses have more residents.
//" if the sum of even array elements is greater than the sum of odd ones.