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
3
Please refer the attached image
Attachments:
Answered by
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
Economy,
3 months ago
Math,
3 months ago
Math,
8 months ago
Social Sciences,
1 year ago
Business Studies,
1 year ago