Addition with different Parameters.
import java.util.*;
class addition
{
Scanner kb=new Scanner(System.in);
void add(int a,int b)
{
int c;
c=a+b;
System.out.println("addition of two integer is:"+c);
}
void add(int k,int l,int m)
{
int n;
n=k+l+m;
System.out.println("addition of three integer is:"+n);
}
void add(int x, int y, int z, int o)
{
int p;
p=x+y+z+o;
System.out.println("addition of four integer is:"+p);
}
public static void main(String arg[])
{
addition ob=new addition();
ob.add(4,5);
ob.add(4,5,7);
ob.add(4,5,9,10);
}
}
Output:
No comments:
Post a Comment