Originally Posted by
alias22
... the only way I can really see where i'm going wrong is if someone actually writes a 100% working code...
I'll go half-way. I will write 100% working pseudo-code.
There are a number of ways to organize the program, and you don't have to do it the way that I will illustrate, but unless you see a way more suitable to your capabilities, I suggest that you try the following:
(You have already done the first couple of things, but I include them here for completeness.)
Declare Scanner object for System.in
Declare variables for numbers, total, numPos, numNeg.
Initialize all to values of zero.
Prompt for a non-zero integer
Declare an int variable named n and set its value from the Scanner object
Repeat the following loop as long as n is not equal to zero:
BEGIN LOOP
Increment the numbers variable.
Add the value of n to the total variable.
IF n IS GREATER THAN ZERO THEN
INCREMENT numPos
ELSE IF n IS LESS THAN ZERO THEN
INCREMENT numNeg
END IF
Prompt for a non-zero integer
Set n to the value read by the Scanner object
END LOOP
Print out numPos, numNeg, total
If numbers IS GREATER THAN ZERO THEN
Calculate and print average = total/numbers
END IF
If there is any part of it that you don't understand or don't see how to make Java out of it then ask specific questions.
Cheers!
Z