Rewrite the following using ternary operator:

if (bill > 10000 )
discount = bill * 10.0/100;
else
discount = bill * 5.0/100;

Single Choice
Views 58

Answer:


discount = bill > 10000 ? bill * 10.0/100 : bill * 5.0/100;

Related Articles:

This section is dedicated exclusively to Questions & Answers. For an in-depth exploration of Java Programming Language, click the links and dive deeper into this subject.

Join Our telegram group to ask Questions

Click below button to join our groups.