New Batch#100 (10th Nov 2021) - Salesforce Admin + Dev Training (WhatsApp: +91 - 8087988044) :https://t.co/p4F3oeQagK

Showing posts with label To perform arithmetic operations (APEX). Show all posts
Showing posts with label To perform arithmetic operations (APEX). Show all posts

Saturday, 26 May 2012

To perform arithmetic operations (APEX)



public class arthematic { 
   
    public Integer num1 { get; set; }

    public Integer num2 { get; set; }
   
    public Integer sum { set; }//If we take inputbox then only we need this, if use outputtext this datamember is not required
   
    public Integer diff { set; }
   
    public Integer mul { set; }
   
    public Integer div { set; }    
  
    public PageReference addition() {
   
        //return null;
        return Page.arthematic;
    }
   
    public arthematic() {
        num1 = num2 = 0;       
    }   
   
   //Addition
    public Integer getSum() {
        //return num1 + num2;       
        return add();
    }   
    public Integer add() {       
        return num1 + num2;
    }
   
    //Subtraction
    public Integer getDiff() {
        //return num1 + num2;       
        return diff();
    }   
    public Integer diff() {       
        return num1 - num2;
    }
   
    //Multiplication
    public Integer getMul() {
        //return num1 + num2;       
        return mul();
    }   
    public Integer mul() {       
        return num1 * num2;
    }
   
    //Division
    public Integer getDiv() {
        //return num1 + num2;       
        return div();
    }   
    public Integer div() {       
        return num1 / num2;
    }/*//<apex:commandButton value="div"/>
//<apex:outputText value="{!div}"/><br></br><br></br>*/ //Getting Exception
   
    }

***********
***********

Labels