Afraid that hint isn't as good as you would think. I suggest you find out about the ?: operator which allows you to calculate the absolute value of an int in one line. ?: acts as an if‑else compressed into one line. There is an example in the old Sun style guide.
E Baller wrote:. . . If n is negative, treat as the absolute value. . . . Hint: Use an if statement . . .
Please indent your code correctly; the contents of the for and if should be 3 spaces to the right and the } should align vertically with if (lines 19 and 21). Remember who will have the most difficulty if your code becomes illegible. You.
E Baller wrote:. . .