package controller;
import java.io.IOException;
import helper.Reader;
public class ArrayExercise2 {
public static void main(String[] args) throws IOException {
int input[] = new int[5];
double summed = 0, average = 0;
int i=0, odd = 0, even = 0;
for(i = 0;i<5;i++)
{
input[i]=Reader.readInt("\nPlease enter a number ");
}
summed = summation(input);
average = getAverage(input);
odd = getOdd(input);
even = getEven(input);
System.out.println("\nSummation = "+ summed +
"\nAverage = " + average +
"\nEven = " + even +
"\nOdd = " + odd);
}
public static double summation(int input[])
{
double sum = 0;
for (int i = 0; i < 5; ++i) {
sum = sum + input[i];
}
return sum;
}
public static double getAverage(int input[])
{
double average = 0;
for (int i = 0; i < 5; ++i) {
average = average + input[i];
}
return average/5;
}
public static int getOdd(int input[])
{
int odd = 0;
for (int i = 0; i < 5; ++i)
{
if(input[i]%2 == 1)
++odd;
}
return odd;
}
public static int getEven(int input[])
{
int even = 0;
for (int i = 0; i < 5; ++i)
{
if(input[i]%2 == 0)
++even;
}
return even;
}
}