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
Hiral Patel 25Hiral Patel 25 

write down visual force page

write down visual force page

                                    CALCULATOR

First Number ::  box
Second Number : :   box
Result:: box

Add     SUB    MUL  DIV

Everything in box
ANUTEJANUTEJ (Salesforce Developers) 
Hi HIral,

You can check the below implementation:
 
VisualforcePage
<apex:page controller="Sample">

<apex:form >
   
    <apex:pageBlock >
        <apex:pageBlockSection >
            <apex:pageBlockSectionItem >
                <apex:outputLabel value="Value 1"/>
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem >
                <apex:inputText value="{!val1}"/>
            </apex:pageBlockSectionItem>                          
            <apex:pageBlockSectionItem >
                <apex:outputLabel value="Value 2"/>
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem >
                <apex:inputText value="{!val2}"/>
            </apex:pageBlockSectionItem>                         
            <apex:pageBlockSectionItem >
                <apex:selectRadio value="{!func}" layout="pageDirection">
                    <apex:selectOption itemValue="add" itemLabel="Add"/>
                    <apex:selectOption itemValue="sub" itemLabel="Subtract"/>
                    <apex:selectOption itemValue="div" itemLabel="Division"/>
                    <apex:selectOption itemValue="mod" itemLabel="Modulo Division"/>
                </apex:selectRadio>
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem >               
            </apex:pageBlockSectionItem>       
            <apex:pageBlockSectionItem >
                <apex:outputLabel value="Result"/>
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem >
                <apex:inputText value="{!result}" id="res"/><apex:actionStatus id="sts" startText="Finding..."/>
            </apex:pageBlockSectionItem>                                      
        </apex:pageBlockSection>   
        <apex:pageBlockButtons >
            <apex:commandButton value="Find" action="{!find}" reRender="res"  status="sts"/>
        </apex:pageBlockButtons>
    </apex:pageBlock>
   
</apex:form>

</apex:page>

Apex Code:

public class Sample
{   
    public Double val1 {get;set;}
    public Double val2 {get;set;}
    public Double result {get;set;}
    public String func {get;set;}
   
    public Sample()
    {
    }
   
    public void find()
    {
        if(func == 'add')
        {
            result = val1 + val2;
        }
        else if(func == 'sub')
        {
             result = val1 - val2;
        }
        else if(func == 'div')
        {
             result = val1 / val2;
        }
        else
        {
             Integer temp =  math.mod(Integer.valueOf(val1) , Integer.valueOf(val2));
             result = Double.valueOf(temp);
        }
    }
  
}

reference: https://www.infallibletechie.com/2013/01/sample-caluculator-using-apex-in.html

I would also suggest you to checkout lightning implementation: https://www.biswajeetsamal.com/blog/simple-calculator-using-salesforce-lightning-components/

Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.  

Thanks.
Hiral Patel 25Hiral Patel 25
its not work.Give proper solution please..
ANUTEJANUTEJ (Salesforce Developers) 
It worked in my org where are you facing the problem?
 
Hiral Patel 25Hiral Patel 25
its totally different i want in this structure 

CALCULATOR

First Number ::  box
Second Number : :   box
Result:: box

Add     SUB    MUL  DIV

Everything in box
ANUTEJANUTEJ (Salesforce Developers) 
Please try this snippet.

<apex:page controller="Sample">
    
    <apex:form style="border:black">        
        <apex:pageBlock >
            <apex:pageBlockSection >
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Value 1"/>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:inputText value="{!val1}"/>
                </apex:pageBlockSectionItem>                          
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Value 2"/>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:inputText value="{!val2}"/>
                </apex:pageBlockSectionItem>                               
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Result"/>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:inputText value="{!result}" id="res"/>
                    <apex:actionStatus id="sts" startText="Finding..."/>
                </apex:pageBlockSectionItem>                                      
            </apex:pageBlockSection>   
            <apex:pageBlockButtons >
                <apex:commandButton value="add" action="{!add}" reRender="res"  status="sts"/>
                <apex:commandButton value="sub" action="{!sub}" reRender="res"  status="sts"/>
                <apex:commandButton value="div" action="{!div}" reRender="res"  status="sts"/>
                <apex:commandButton value="mod" action="{!mod}" reRender="res"  status="sts"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
        
    </apex:form>
    
</apex:page>
public class Sample
{   
    public Double val1 {get;set;}
    public Double val2 {get;set;}
    public Double result {get;set;}
    public String func {get;set;}
    public Sample()
    {
    }
    public void add()
    {
        result = val1 + val2;
    }
    public void sub()
    {
        result = val1 - val2;
    }
    public void div()
    {
        result = val1 / val2;
    }
    public void mod()
    {
        Integer temp =  math.mod(Integer.valueOf(val1) , Integer.valueOf(val2));
        result = Double.valueOf(temp);
    }
}