Traditional Culture Encyclopedia - Traditional virtues - I. Write a Java program to simulate a simple calculator.

I. Write a Java program to simulate a simple calculator.

public class Number {

private Integer n1;

private Integer n2;

/** Constructor methods */

public Number(Integer n1, Integer n2) {

super();

this.n1 = n1;

this.n2 = n2;

}

/** addition */

public Integer addition() {

System.out.println(this. n1 + this.n2);

return this.n1 + this.n2;

}

}

/** Subtraction */

public Integer subtration() {

System.out.println(this.n1 - this.n2);

return this.n1 - this.n2;

}

/** Multiplication */

public Integer multiplication() {

System.out.println(this.n1 * this.n2);

return this.n1 * this.n2;

}

/** divide */

public Integer division() {

System.out.println(this.n1 / this. n2);

return this.n1 / this.n2;

}

public Integer getN1() {

return n1;

}

public void setN1(Integer n1) {

this.n1 = n1;

}

public Integer getN2() {

return n2;

}

public void setN2(Integer n2) {

this.n2 = n2;

}

}

public static void main(String[] args) {

Number number = new Number(1, 2);

number.addition();

number. subtration();

number.multiplication();

number.division();

}