Computer Applications

Rewrite the following using ternary operator.

if(p>5000)
d = p*5/100;
else
d = 2*p/100;

Java Operators

141 Likes

Answer

d = p > 5000 ? p * 5 / 100 : 2 * p / 100;

Answered By

83 Likes


Related Questions