Computer Science, asked by masternavya, 8 months ago

Rewrite the following using if-else statement (converts into if-else)
1.). double com = (sale>5000)?sale - 10/100: 0;
2.). double net =(salary > 10000)? salary - (8. 33/100) salary: salary - (5/100) salary,​

Answers

Answered by rohitkhajuria90
3

Please refer the attached image

Attachments:
Answered by anindyaadhikari13
2

Question:-

  • Rewrite the following using if-else statement.

Solution:-

Given code,

double com=(sale>5000)?sale-10/100:0;

This can be written using if else statement as,

double com;

if(sale>5000)

com=sale-10/100;

else

com=0;

Again,

double net=(salary>10000)?salary-(8.33/100):salary-(5/100);

This can be written using if else statement as,

double net;

if(salary>10000)

net=salary-(8.33/100);

else

net=salary-(5/100);

Similar questions