98.4k views
1 vote
I NEED SOMEONE TO ANSWER THIS NOW PLS

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.
IDK HOW to do this and this question is on my homework which is due TODAY

1 Answer

7 votes

Answer:

if (value > 0)

System.out.println("positive");

else if (value < 0)

System.out.println("negative");

else

System.out.println("neither");

Step-by-step explanation:

User KaJasB
by
3.5k points