Java

Java - Method with Parameter

Java - Method with Parameter
class fun1 
{ 
int a, b; 

void calc(int x,int y) 
{ 
a = x; 
b = y; 
} 

void add() 
{ 
System.out.println("\nAddition :"+(a+b)); 
} 

void sub() 
{ 
System.out.println("\nSubtraction :"+(a-b)); 
} 

void mul() 
{ 
System.out.println("\nMultiplication :"+(a*b)); 
} 

void div() 
{ 
System.out.println("\nDivision :"+(a/b)); 
} 

void rem() 
{ 
System.out.println("\nModules :"+(a%b)); 
} 

public static void main(String arg[]) 
{ 
fun1 x; 
x = new fun1(); 

x.calc(10,3); 

x.add(); 
x.sub(); 
x.mul(); 
x.div(); 
x.rem(); 
} 
}
Senthilvelan Sambamoorthy

Senthilvelan Sambamoorthy is working as a Professor in Department of Master of Computer Applications, Paavai Engineering College, Namakkal, Tamilnadu, India, He is Masters in Computers Applications. Having 18+ years of experience and his area of interest is Java, JSP, Servlet, J2EE, C#, PHP, Python ASP.NET, SQL Server and etc.