Rewrite the following program segment using Ternary operators
if (sales >= 100000)
double discount = sales * 0.25;
else
double discount = sales * 0.1;
Answers
Answered by
6
Question:-
➡ Rewrite the following using ternary operator.
Solution:-
This is the converted code snippet,
double discount = (sales>=100000)?sales*0.25:sales*0.1;
Answered by
1
Question:-To convert the following snippet into ternary operator.
if(sales>=100000)
double discount=sales*0.25:
else
double discount =sales*0.1;
Using ternary operator:-
double discount=(sales>=100000) sales*0.25:sales*0.1;
Similar questions