Labels and numbers

  • 4
  • Locked
Not all labels are equally useful, but sometimes a lack of labels results in chaos. Let's do a task that dishes out labels: use the keyboard to enter an integer, and make the program indicate whether the number is negative or positive (or zero), and even or odd. Why do we need this? Just because, for practice. After all, we're here to learn!
You can't complete this task, because you're not signed in.
Comments (12)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Level 9 , Milan, Italy
20 October 2022, 18:26
hi after an afternoon i understood that the text could be cut in two different string "negative" .... "even number" ....
Level 10 , Italy
9 October 2022, 14:33
Is possible do this task with switch?
Ice_ Beam
Level 7 , Germany
19 April 2021, 11:24
I have a question regarding my formula:
if (number % 2 == 1 && number < 0) {
                System.out.println("Negative odd number");

if (number % 2 == 1 && number > 0) {
                System.out.println("Positive odd number");
Why won't it print out anything for the negative odd formula? I mean the other odd positive formula was the same, but it printed out the results. Am I missing a hidden rule here? it only worked when I changed it to != 0 instead of ==1
Level 41
23 April 2021, 05:28
Try this:
int n = -1;
System.out.println(n % 2);
and look at the result)
Joe M
Level 47 , Owings Mills, United States
28 September 2020, 17:31
got it but still IJ is giving me the "not using println()" error....copied/pasted into here and no issues
Ganesh Kumar S M
Level 5 , Amsterdam, Netherlands
2 January 2020, 15:20
If the exercise is too hard or if we make minor mistakes then I believe we need to know the answers. I know we have to try ourselves to complete the task but sometimes we also need to know the answers to the tasks so that we can see if we can improve the answers. Please have a separate section for the correct answers. That will help a lot.
Level 6 , Allentown, United States
16 March 2021, 21:57
You can review and download the correct answer from the help menu.
Richard Melton
Level 7 , St Louis, United States
16 December 2019, 22:44
ok so is my logic off or did I screw up the syntax anybody have any suggestions?
Kent Hervey Software Engineer/Consult at Zeal IT ConsultantsExpert
14 October 2019, 16:24
Why doesn't this work for negative numbers? if(enteredNumber%2==1){ System.out.println("is odd"); }
Kent Hervey Software Engineer/Consult at Zeal IT ConsultantsExpert
14 October 2019, 16:46
Because the result would be -1...I solved by using -1. but in real life I might use abs
Michael Martin
Level 19 , Arlington, United States
2 November 2018, 18:59
Can anyone tell me why the conditions no longer appear on the left hand side? It's really annoying to copy the conditions to notepad just so I can look at them while I am coding. When I started this course, they showed up on the left side, but then something happened, and now I only get the folder structure. Anyone know of any way to change this? Thanks!
Level 41
6 November 2018, 08:00
Thank you very much, we will take into account your wishes. In future releases this will be implemented.