September 16, 2020
class Calculator_class{
int left, right;
int total = 0;
public void setOperands(int left, int right){
this.left = left;
this.right = right;
}
public int sum(){
total = this.left + this.right;
return total;
}
public int sub(){
total = this.left - this.right;
return total;
}
public int mul(){
total = this.left * this.right;
return total;
}
public int div(){
total = this.left / this.right;
return total;
}
}
public class Calculator{
public static void main(String[] args) {
Calculator_class cal = new Calculator_class();
cal.setOperands(25,10);
System.out.println(cal.sum());
System.out.println(cal.sub());
System.out.println(cal.mul());
System.out.println(cal.div());
}
}
class Calculator_class{
int left, right;
int total = 0;
//
public Calculator_class(int left, int right){
this.left = left;
this.right = right;
}
public int sum(){
total = this.left + this.right;
return total;
}
public int sub(){
total = this.left - this.right;
return total;
}
public int mul(){
total = this.left * this.right;
return total;
}
public int div(){
total = this.left / this.right;
return total;
}
}
public class Calculator{
public static void main(String[] args) {
Calculator_class cal = new Calculator_class(25,10);
System.out.println(cal.sum());
System.out.println(cal.sub());
System.out.println(cal.mul());
System.out.println(cal.div());
}
}
class Calculator_set{
int left, right;
int total = 0;
public void setOperands(int left, int right){
this.left = left;
this.right = right;
}
}
class Calculator_func extends Calculator_set{
public int sum(){
total = this.left + this.right;
return total;
}
public int sub(){
total = this.left - this.right;
return total;
}
public int mul(){
total = this.left * this.right;
return total;
}
public int div(){
total = this.left / this.right;
return total;
}
}
public class Calculator {
public static void main(String[] args) {
Calculator_func cal = new Calculator_func();
cal.setOperands(25,10);
System.out.println(cal.sum());
System.out.println(cal.sub());
System.out.println(cal.mul());
System.out.println(cal.div());
}
}