Rewrite the following if-else statements as statements that use the conditional operator. a) if (x > y)
Question:
Rewrite the following if-else statements as statements that use the conditional operator.
a) if (x > y)
z = 1;
else
z = 20;
b) if (temp > 45)
population = base * 10;
else
population = base * 2;
c) if (hours > 40)
wages *= 1.5;
else
wages *= 1;
d) if (result >= 0)
System.out.println("The result is positive.");
else
System.out.println("The result is negative.");
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Related Book For
Starting Out With Java From Control Structures Through Data Structures
ISBN: 9780133957051
6th Edition
Authors: Tony Gaddis
Question Posted: