Ask Question
25 May, 18:26

Assume the availability of an existing class, ICalculator, that models an integer arithmetic calculator and contains: an instance variable currentValue that stores the current int value of the calculator a getter method for the above instance variable methods add, sub, mul, and div Each method in ICalculator receives an int argument and applies its operation to currentValue and returns the new value of currentValue. So, if currentValue has the value 8 and sub (6) is invoked then currentValue ends up with the value 2, and 2 is returned. So, you are to write the definition of a subclass, ICalculator1, based on ICalculator. The class ICalculator1 has one additional method, sign, that receives no arguments, and doesn't modify currentValue. Instead, it simply returns 1, 0 or - 1 depending on the whether currentValue is positive, zero, or negative respectively

+2
Answers (1)
  1. 25 May, 19:05
    0
    The following program are:

    public class ICalculator2 extends ICalculator {

    public int negate () {

    currentValue = - currentValue;

    return currentValue;

    }

    }

    Explanation:

    In the following program firstly, we declare the class "ICalculator2" with the access modifier "public" and it inherits the class "ICalculator".

    Then we set the integer type function "negate () " with the access modifier "public".
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Assume the availability of an existing class, ICalculator, that models an integer arithmetic calculator and contains: an instance variable ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers