106k views
1 vote
Consider the following code segment:

if (value > 0)
System.out.println("positive");
if (value < 0)
System.out.println("negative");
if (value == 0)
System.out.println("neither");

Rewrite the code in the space below so that it uses an if-else structure instead of 3 if statements.

1 Answer

4 votes

Answer:

if (value > 0)

System.out.println("positive");

else

if (value < 0)

System.out.println("negative");

else

System.out.println("neither");

Hope its right :)

User Suave
by
5.1k points