Tell me where is the error? Cannot handle division by zero.
public class Calculator_OOP { public static void main(String[] args) { CalculatorLogic calclogic = new CalculatorLogic(); Calculator calc = new Calculator(calclogic); calc.exec(); } } interface Operation { double exec(double first_value, double second_value); } class Addition implements Operation { public double exec(double first_value, double second_value) { return (first_value + second_value); } } class Subtraction implements Operation { public double exec(double first_value, double second_value) { return (first_value - second_value); } } class Multiply implements Operation { public double exec(double first_value, double second_value) { return (first_value * second_value); } } class Division implements Operation { public double exec(double first_value, double second_value) { if (second_value==0) { throw new DivisionByZero(); } return (first_value / second_value); } } interface Operations { Operation getOper(char op); } class CalculatorLogic implements Operations { char resOperation; public Operation operation; public Operation getOper(char op) { this.resOperation = op; switch (resOperation) { case '+': { operation = new Addition(); break; } case '-': { operation = new Subtraction(); break; } case '*': { operation = new Multiply(); break; } case '/': { operation = new Division(); break; } default: } return operation; } } class Calculator { CalculatorLogic resultOperation; public Calculator(CalculatorLogic resultOperation) { this.resultOperation = resultOperation; } public void exec() { Scanner scanner = new Scanner(System.in); try { System.out.println("Введите первое число и нажмите Enter"); double num1 = scanner.nextDouble(); System.out.println("Выберите операцию: +, -, *, / и нажмите Enter"); char operation = scanner.next().trim().charAt(0); System.out.println("Введите второе число и нажмите Enter"); double num2 = scanner.nextDouble(); Operation op = resultOperation.getOper(operation); if (op != null) System.out.println("Ответ: " + op.exec(num1, num2)); else System.out.println("Error: Не верная операция!"); } catch (Exception e) { System.out.println("Ошибка: Не верное значение!"); } } public class DivisionByZero extends Exception {}