Sunday 5 June 2011


This is simple java program explaining calling with simple application of calculator with different operators
code shared by UMANG MISTRY X(VISSANJI ACADEMY)

Code:
/*
 *this is simple java program explaining calling with simple application of calculator with different operators
 */

public class calcuator
{
public void caladd(int no1, int no2)//RECIEVING VALUES
{
int result = no1 + no2;//calculating and assigning value to result
System.out.println(" addition = "+result);
}
public void calsub(float fno1, float fno2)//RECIEVING VALUES
{
float fresult = fno2 - fno1;//calculating and assigning value to result
System.out.println("subs ="+fresult);
}
   public void calmulti(long no1, long no2)//RECIEVING VALUES
     {
long result = no1 * no2;//calculating and assigning value to result
System.out.println("multi = "+result);
}
public void caldiv (double no1, double no2)//RECIEVING VALUES
{
double result = no2 / no1;//calculating and assigning value to result
System.out.println("div = "+result);
}
   public void main ()
   {
       int afno = 1 , asno = 2;//ASSIGNING VALUES
       float ffno = 2 , fsno = 3;//ASSIGNING VALUES
       long mfno = 3 , msno = 4;//ASSIGNING VALUES
       double dfno = 5, dsno = 6;//ASSIGNING VALUES
       caladd(afno,asno);//CALL FUNCTION caladd AND PASSING VALUE
       calsub (ffno, fsno);//CALL FUNCTION calsub AND PASSING VALUE
       calmulti(mfno,msno);//CALL FUNCTION calmulti AND PASSING VALUE
       caldiv(dfno,dsno);//CALL FUNCTION caldiv AND PASSING VALUE
    }
}

Comment bellow for your query and feedback... :)

Related Posts :



0 comments:

Confused? Feel free to ask

Post a Comment