> I need some help with this JAVA Program?

I need some help with this JAVA Program?

Posted at: 2014-12-18 
Change this line:

int num = input.nextInt();

to:

int num = 0;

Write a program that reads an unspecified number of integers , determines how many positive and negative values have been read, and computes the total and average of the input values (not counting zeros). Your program ends with the input 0. Display the average as a floating-point number.

Here is what I have so far:

import java.util.Scanner;

public class Avg {

public static void main(String[] args) {



int positive = 0;

int negative = 0;

int count = 0;

double avg =0;



Scanner input = new Scanner(System.in);



System.out.print("Enter an integer, the input ends if it is 0: ");

int num = input.nextInt();



double sum = 0;

while ((num = input.nextInt()) != 0) {

sum += num;

if (num > 0) {

positive++;

count++;

}

if (num < 0) {

negative++;

count++;

}

if (num ==0) {

break;

}

}

avg = sum / count;

System.out.println("The number of positives is: " + positive);

System.out.println("The number of negatives is: " + negative);

System.out.println("The total is: " + sum);

System.out.println("The average is: " + avg);



}

}

This input that I put in is 1 2 3 -1 0

I keep on getting this output:

The number of positives is: 2

The number of negatives is: 1

The total is: 4.0

The average is: 1.3333333333333333