Scanner s = new Scanner(System.in);
int times;
times = s.nextInt(); //brings in an int from commandline
times = times < 0 ? -times : times;
int notes = times++;
if (times-- > 5 || notes == times)
notes *= (times-2);
else if (times%4==1 && notes < times)
notes += times - 1;
if (-times > -notes)
System.out.println(notes);
else
System.out.println(times);
What input was given to the following code snippet to output 8?
Under discussion
Comments (1)
- Popular
- New
- Old
You must be signed in to leave a comment
Thomas
28 August, 07:20
why do you not just write:
Then you easily can see that -4 and 4 will output 8. 0