You are required to build a class ArithematicProblem that represent a binary arithematic problem such as addition, subtraction, multiplication and division. The ArithematicProblem class is a super class which is there to provide the most generic version of the ArithematicProblem concept. This class has following instance variables 1. Operator1 (double) 2. Operator2 (double) 3. Answer(double) 4. Error(boolean) The value of Operator1 and Operator2 will be initialized through parameters in the constructor while the value of answer is Double.POSITIVE_INFINITY and error is false by default. Provide getters for all but setters for only operand1 and operand2 Provide the toString method so that the string representation of each operation the standard representation in mathematics i.e. if its an addition problem then it should be printed as 2 + 3 = 5 and so on. Provide a method double solve() in this class. This method performs the arithematic operation on the operands, calculates answer, sets the value of answer and returns it. If an error occurs in the calculation then the error is set to true and answer remains Double.POSITIVE_INFINITY. Since in the super class ArithematicProblem, we do not know what to do (beccause it is not one of the standard 4 operations), you will simply return the answer (Double.POSITIVE_INFINITY) Now provide the subclasses AdditionProblem, SubtractionProblem, MultiplicationProblem and DivisionProblem. All of these class inherit from ArithematicProblem. Provide appropriate constructors and the toString method. Now override the solve method in each of these class to do the appropriate operation. i.e. If it is AdditionProblem then you will add the operands in the solve method, 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 will perform the division but if the divisor i.e. the second operand is 0 then the division goes into error. So you will check for this situation and if the divisor is O then you will not solve, rather set the error to true and return the answer unchanged. (L.e. POSITIVE_INFINITY, the default value). Other instructors will be given in the class -I-X + 1

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
You are required to build a class ArithematicProblem that represent a binary
arithematic problem such as addition, subtraction, multiplication and division.
The ArithematicProblem class is a super class which is there to provide the most
generic version of the ArithematicProblem concept. This class has following
instance variables
1. Operator1 (double)
2. Operator2 (double)
3. Answer(double)
4. Error(boolean)
The value of Operator1 and Operator2 will be initialized through parameters in the
constructor while the value of answer is Double.POSITIVE_INFINITY and error is false
by default.
Provide getters for all but setters for only operand1 and operand2
Provide the toString method so that the string representation of each operation
the standard representation in mathematics i.e. if its an addition problem then it
should be printed as 2 + 3 = 5 and so on.
Provide a method double solve() in this class. This method performs the arithematic
operation on the operands, calculates answer, sets the value of answer and returns it. If an error occurs
in the calculation then the error is set to true and answer remains Double.POSITIVE_INFINITY. Since in
the super class ArithematicProblem, we do not know what to do (beccause it is not one of the standard
4 operations), you will simply return the answer (Double.POSITIVE_INFINITY)
Now provide the subclasses AdditionProblem, SubtractionProblem,
MultiplicationProblem and DivisionProblem. All of these class inherit from
ArithematicProblem. Provide appropriate constructors and the toString method.
Now override the solve method in each of these class to do the appropriate
operation. i.e. If it is AdditionProblem then you will add the operands in the solve
method, 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 will
perform the division but if the divisor i.e. the second operand is 0 then the division goes into error. So
you will check for this situation and if the divisor is O then you will not solve, rather set the error to true
and return the answer unchanged. (I.e. POSITIVE_INFINITY, the default value).
Other instructors will be given in the class
-I-X
Transcribed Image Text:You are required to build a class ArithematicProblem that represent a binary arithematic problem such as addition, subtraction, multiplication and division. The ArithematicProblem class is a super class which is there to provide the most generic version of the ArithematicProblem concept. This class has following instance variables 1. Operator1 (double) 2. Operator2 (double) 3. Answer(double) 4. Error(boolean) The value of Operator1 and Operator2 will be initialized through parameters in the constructor while the value of answer is Double.POSITIVE_INFINITY and error is false by default. Provide getters for all but setters for only operand1 and operand2 Provide the toString method so that the string representation of each operation the standard representation in mathematics i.e. if its an addition problem then it should be printed as 2 + 3 = 5 and so on. Provide a method double solve() in this class. This method performs the arithematic operation on the operands, calculates answer, sets the value of answer and returns it. If an error occurs in the calculation then the error is set to true and answer remains Double.POSITIVE_INFINITY. Since in the super class ArithematicProblem, we do not know what to do (beccause it is not one of the standard 4 operations), you will simply return the answer (Double.POSITIVE_INFINITY) Now provide the subclasses AdditionProblem, SubtractionProblem, MultiplicationProblem and DivisionProblem. All of these class inherit from ArithematicProblem. Provide appropriate constructors and the toString method. Now override the solve method in each of these class to do the appropriate operation. i.e. If it is AdditionProblem then you will add the operands in the solve method, 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 will perform the division but if the divisor i.e. the second operand is 0 then the division goes into error. So you will check for this situation and if the divisor is O then you will not solve, rather set the error to true and return the answer unchanged. (I.e. POSITIVE_INFINITY, the default value). Other instructors will be given in the class -I-X
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education