You are on page 1of 1

interface calculator { void sum(int a,int b); void sub(int a,int b); void mul(int a,int b); void

div(int a,int b); } class mathprocessor implements calculator { public void add(int a,int b){ int z; z=a+b; System.out.println("z"); } public void sub(int a,int b){ int r=a-b; System.out.println("r"); } public void mul(int a,int b){ int c=a*b; System.out.println("c"); } public void div(int a,int b){ int z=0; if(b==0){ System.out.println("division not allowed"); } else{ z=a+b; System.out.println("z"); } } class calculatorinter { public static void main(String[]args) { mathprocessor m=new mathprocessor(); mathprocessor m1=new mathprocessor(); mathprocessor m2=new mathprocessor(); mathprocessor m3=new mathprocessor(); System.out.println("1.addition: 100 , 50"); m.sum(100,50); System.out.println("2.subtraction: 100 , 50"); m.sub(100,50); System.out.println("3.multiplication: 100 , 50"); m.mul(100,50); System.out.println("4. division: 100 , 50"); m.div(100,50); } }

You might also like