public class Main {
public static void main(String[] args) {
int x = 19;
int y = 42;
Arithmetic a = new Arithmetic(x, y);
System.out.println("сумма чисел " + x + " и " + y + " -> " + a.sum());
System.out.println("произведение чисел " + x + " и " + y + " -> " + a.product());
System.out.println("максимальное из чисел " + x + " и " + y + " -> " + a.max());
System.out.println("минимальное из чисел " + x + " и " + y + " -> " + a.min());
}
}
public class Arithmetic {
private int x;
private int y;
public Arithmetic(int x, int y) {
this.x = x;
this.y = y;
}
public int sum() {
return this.x + this.y;
}
public int product() {
return this.x * this.y;
}
public int max() {
return this.x > this.y ? this.x : this.y;
}
public int min() {
return this.x < this.y ? this.x : this.y;
}
}