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;
public class test
     public static void 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!

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

Similar Messages

Maybe you are looking for

  • Wireless Function Not Working Correctly

    When I try to print wirelessly, it prints 2-3 pages and then quits printing, often right in the middle of a page, and tells me there was a printing error. When I print through a cable, it works perfectly. The printer is about 13 feet away from the in

  • TEXT DISAPPEARS

    I recently ugraded to appleworks 6 from 5 on a PC with Win XP Pro. I had a database created in 5 which was imported to 6. My problem is that when I create a new record and I type in text, when I move to the next field the text disappears. If I go int

  • Problem pricing CRMD_BUS2000115

    We have a problem in transaction CRMD_BUS2000115. The pricing is not based on field "PricingRefProd." when we fill in this field with the BADI method CRM_PRODUCT_I_MERGE. We enter product 'A'. This is automatically replaced by 'B', thats fine, but we

  • Pop-up message during MIRO

    Dear sir , In Service Master for a specific type of services where "work contrct tax" is applicable , we mention Service Type as "WCT" . Our requirement is that at the time of MIRO , a message / pop-up message should be appeared on screen indicating

  • How can I turn document saved in Acrobat PDF back into multipage AI PDF document.

    I accidentally saved my multipage AI PDF document in acrobat. Now i can't open it in AI as it original multipage AI PDF document. How can I access tye document in it original multipage AI PDF document format?