import java.util.Scanner;
public class CountPosAndNegNumbers {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int positive = 0;
int negative = 0;
int averagePos = 0;
int averageNeg= 0;
System.out.println("Enter an integer, the input ends if it is 0:");
int numbers = input.nextInt();
do {
if (numbers > 0)
{
positive += numbers;
}
else if (numbers < 0)
{
negative += numbers;
}
numbers = input.nextInt();
averagePos = Math.round(positive);
averageNeg = Math.round(negative);
} while (numbers != 0);
System.out.println("The number of positives is:" + positive);
System.out.println("The number of negatives is:" + negative);
System.out.println("Average of positive numbers:" + averagePos);
System.out.println("Average of negative numbers:" + averageNeg);
}
}
I need help to find the average of the integers that are input but can't manage to solve the problem.