Can someone please help... I'm stuck!!!

I am working on an assignment for my java class, and I am stuck. This is the 1st programming class that i have taken and am a little confused. I am supposed to write a program that inputs 5 numbers and determines and prints the number of negative numbers, positive numbers, and zeros that were inputed.

This is what i have so far:

import java.util.Scanner;

publicclass test

{

publicstaticvoid main (String[] args)

{

Scanner input =new Scanner (System.in);

int number;

int negative = 0;

int positive = 0;

int zero = 0;

int numberCounter = 1;

while (numberCounter <=5)

{

System.out.print("Please enter a number:");

number = input.nextInt();

if (number == 0)

zero = zero +1;

else

negative=negative+1;

numberCounter = numberCounter + 1;

}

System.out.printf(" Positive: %d\n Negative: %d\n Zero: %d\n", positive, negative, zero);

}

}

I don't know how to add another arugment to the if statement for the positive numbers. As of right now, it only correctly adds the zeros and displays the rest as negative numbers. Thank you!

[1914 byte] By [javarookie01a] at [2007-10-2 20:35:03]
# 1
hi :-)try using else-if, something like thisif (number == 0){zero = zero +1;}else if (number > 0) {positive = positive + 1;}else {negative=negative+1;}regards :-)
jie2eea at 2007-7-13 23:18:15 > top of Java-index,Java Essentials,New To Java...
# 2

> I don't know how to add another arugment to the if

> statement for the positive numbers. As of right now,

> it only correctly adds the zeros and displays the

> rest as negative numbers. Thank you!

if (something) {

do stuff

}

else if (something else) {

do other stuff

}

else {

handle the rest

}

jverda at 2007-7-13 23:18:15 > top of Java-index,Java Essentials,New To Java...
# 3
And next time...* Please stick to one thread for one problem.* Please skip all the !!! and the bold. It won't make people answer any faster--it's just annoying.
jverda at 2007-7-13 23:18:15 > top of Java-index,Java Essentials,New To Java...
# 4

You're almost there; the syntax of an if-then-else statement is easy:

if (<condition>) <statement> else <statement>

The if-then-else thing is a statement itself, so:

if (<condition>) <statement> else if (<condition>)<statement> else <statement>

... is valid too. So your extra condition is simply:if (number == 0)

zero++; // same as zero= zero+1

else if (number > 0)

positive++;

else

negative++;

kind regards,

Jos

JosAHa at 2007-7-13 23:18:15 > top of Java-index,Java Essentials,New To Java...
# 5
And who is the slowest old sod again?kind regards,Jos (strange, I did have my espresso already ;-)
JosAHa at 2007-7-13 23:18:15 > top of Java-index,Java Essentials,New To Java...
# 6
Thank you to everyone who responded with positive feedback... I appreciate the help!
javarookie01a at 2007-7-13 23:18:15 > top of Java-index,Java Essentials,New To Java...