Computer Science, asked by aishaakbar, 5 months ago

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 anindyaadhikari13
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 BrainlyProgrammer
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