interface Compute{
public int compute(int n,int m);
}
class Add implements Compute{
@Override
public int compute(int num1, int num2) {
return num1+num2;
class Subtract implements Compute{
return num1-num2;
class Multiply implements Compute{
return num1*num2;
class Divide implements Compute{
return num1/num2;
}}
class UseCompute{
public void useCom(Compute com, int one, int two){
System.out.println(com.compute(one,two));
public class Test{
public static void main(String args[]){
UseCompute u=new UseCompute();
Add a=new Add();
Divide d=new Divide();
Multiply m=new Multiply();
Subtract s=new Subtract();
System.out.print("35+7=");
u.useCom(a, 35, 7);
System.out.print("35/7=");
u.useCom(d, 35, 7);
System.out.print("35*7=");
u.useCom(m, 35, 7);
System.out.print("35-7=");
u.useCom(s, 35, 7);
interface Compute{
public int compute(int n,int m);
}
class Add implements Compute{
@Override
public int compute(int num1, int num2) {
return num1+num2;
}
}
class Subtract implements Compute{
@Override
public int compute(int num1, int num2) {
return num1-num2;
}
}
class Multiply implements Compute{
@Override
public int compute(int num1, int num2) {
return num1*num2;
}
}
class Divide implements Compute{
@Override
public int compute(int num1, int num2) {
return num1/num2;
}}
class UseCompute{
public void useCom(Compute com, int one, int two){
System.out.println(com.compute(one,two));
}
}
public class Test{
public static void main(String args[]){
UseCompute u=new UseCompute();
Add a=new Add();
Divide d=new Divide();
Multiply m=new Multiply();
Subtract s=new Subtract();
System.out.print("35+7=");
u.useCom(a, 35, 7);
System.out.print("35/7=");
u.useCom(d, 35, 7);
System.out.print("35*7=");
u.useCom(m, 35, 7);
System.out.print("35-7=");
u.useCom(s, 35, 7);
}
}