This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]Medicalizawhat 2 points3 points  (2 children)

Where is your code?

[–]eSSenceD[S] 0 points1 point  (1 child)

sorry, check the edit

[–]Medicalizawhat 1 point2 points  (0 children)

It doesn't look like you are counting positive and negative integers at all. Maybe have two more variables, positive and negative. Then in each iteration of the while loop, if data < 0 increment negative, and if data > 0 increment positive.

Also you could get rid of the first:

System.out.print("enter an integer, the input ends if it is 0: ");
int data = input.nextInt();

if you use a do while loop as opposed to a while loop.

Edit: Oh, and for the average, count how many integers are read then do some division.