in java You are required to build a class ArithematicProblem that represent a binaryarithematic problem such as addition, subtraction, multiplication and division.The ArithematicProblem class is a super class which is there to provide the mostgeneric version of the ArithematicProblem concept. This class has followinginstance variables1. Operand1 (double)2. Operand2 (double)3. Answer(double)4. Error(boolean)The value of Operand1 and Operand 2 will be initialized through parameters in theconstructor while the value of answer is Double.POSITIVE_INFINITY and error is falseby default.Provide getters for all but setters for only operand1 and operand2Provide the toString method so that the string representation of each operationthe standard representation in mathematics i.e. if its an addition problem then itshould be printed as 2 + 3 = 5 and so on.Provide a method double solve() in this class. This method performs the arithematicoperation on the operands, calculates answer, sets the value of answer and returns it. If an error occursin the calculation then the error is set to true and answer remains Double.POSITIVE_INFINITY. Since inthe super class ArithematicProblem, we do not know what to do (beccause it is not one of the standard4 operations), you will simply return the answer (Double.POSITIVE_INFINITY)Now provide the subclasses AdditionProblem, SubtractionProblem,MultiplicationProblem and DivisionProblem. All of these class inherit fromArithematicProblem. Provide appropriate constructors and the toString method.Now override the solve method in each of these class to do the appropriateoperation. i.e. If it is AdditionProblem then you will add the operands in the solvemethod, set the answer to the sum obtained and return this value.In subtraction you will do subtration and multiplication the product. However, in division, you willperform the division but if the divisor i.e. the second operand is 0 then the division goes into error. Soyou will check for this situation and if the divisor is 0 then you will not solve, rather set the error to trueand return the answer unchanged. (I.e. POSITIVE_INFINITY, the default value).
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here