function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Kumar Santosh 17Kumar Santosh 17 

How to write an apex program when Bill amount and Discount given. print the net amount after discount.

How to write an apex program when Bill amount and Discount given as follows

    Bill amount value           Discount(%)
     
      1000 - 5000                     5%   
      5001 - 10000                    10%

 print the net amount to pay(After Discount)
Best Answer chosen by Kumar Santosh 17
Kiran ChodavadiyaKiran Chodavadiya
Try this code with before Insert Trigger.

if (VariableName.Bill_Amount__c => 1000 && VariableName.Bill_Amount__c <=5000) {
     VariableName.Bill_Amount__c = VariableName.Bill_Amount __c - (VariableName.Bill_Amount__c * 0.05);

     system.debug ('The Net Amount After Discount is ' + VariableName.Bill_Amount__c);
}
else 
      if (VariableName.Bill_Amount__c => 5001 && VariableName.Bill_Amount__c <=10000) {
     VariableName.Bill_Amount__c = VariableName.Bill_Amount __c - (VariableName.Bill_Amount__c * 0.1);

     system.debug ('The Net Amount After Discount is ' + VariableName.Bill_Amount__c);
}