Positive and negative numbers

  • 3
  • Locked
Use the keyboard to enter a number. If the number is positive, then double it. If the number is negative, add one. If the entered number is zero, display zero. Display the result on the screen.
You can't complete this task, because you're not signed in.
Comments (5)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Ali-alshehri-11
Level 5 , Saudi Arabia
24 April, 04:24
Nice!
Mindaugas
Level 3 , Lithuania
21 March, 21:20
Task was not quite clear, I think you should remove second requirement and add in the end new requirement that only final number should be displayed.
vhunjek Director at Silikon Studio
26 December 2021, 12:13
Requirement #2 is not clear. It says that first should be displayed the entered number, not the result. If you do that, verifying wouldn't pass. Please change the requirement text to be non-ambiguous.
Roman
Level 41
10 January, 07:43
Please post your question with the attached solution in the section Help.
Hoist
Level 8 , San Diego, United States
21 September 2021, 21:27
I created a "reader" object to name things in the object. It's built from the BufferReader 'stuff' provided by Java to use. Acquire the input variable then manipulate it. I started to scribble out some logic code described in the Tasks. It sounded like if / else could be used ... and we are in Level 3. Hints: the number needs to be greater > than 0 - if so x2 --- if negative number plus one