English

Rewrite the following program segment using if-else statements instead of the ternary operator. net = (salary > 10000) ? salary − (8.33 / 100) * salary : salary − (5 / 100) * salary. - Computer Applications

Advertisements
Advertisements

Question

Rewrite the following program segment using if-else statements instead of the ternary operator.

net = (salary > 10000) ? salary − (8.33 / 100) * salary : salary − (5 / 100) * salary.

Answer in Brief

Solution

double net;
if (salary > 10000) 
net = salary − (8.33 / 100) * salary;
else
net = salary − (5 / 100) * salary; 
shaalaa.com
  Is there an error in this question or solution?
Chapter 1.04: Operators in Java - EXERCISES [Page 44]

APPEARS IN

Avichal Computer Applications [English] Class 10 ICSE
Chapter 1.04 Operators in Java
EXERCISES | Q V. 7. (c) | Page 44
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×