Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I won't provide written code for you, but i will provide hopefully something to help get you thinking.</p> <p>The problem that you're asking for is not too difficult, so you should be able to get it with a little more thought.</p> <p>You seem to be on the right track. The description says you want to print out the number of positive and negative numbers entered AFTER the user inputs 0. At the moment you're outputting it after every user input. &lt;- Think about this a bit, and where you should be putting your output.</p> <p>You're also asking for the nextInt() once outside your while loop. Try trace through the program as you enter a number in, and see what happens. You should fine that you are actually entering 2 integers before the if statements below are called.</p> <p>P.S. You might want to make sure the formatting of your code is decent in the future...</p> <p>EDIT: A little more help:</p> <pre><code>System.out.println( negative += 1 ); </code></pre> <p>Currently does two things, its increasing your counter for the number of negative integers so far, and printing that value out.</p> <p>You're correct that you want to keep incrementing that value every time the while loop is run (and a user puts in a number &lt; 0), but what you don't want to do is print it at that stage of the program as well. Consider breaking that bit of code up into two, and placing the appropriate part in the appropriate location :)</p> <p>So, think about:</p> <p>How to increment a variable by itself, and how to print that variable by itself. Of course, change this for the positive line too.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload