1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Aleonysh [2.5K]
2 years ago
10

Assume the availability of an existing class, ICalculator, that models an integer arithmetic calculator and contains: an instanc

e variable currentValue that stores the current int value of the calculator and can be accessed and modified by any subclass. 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, ICalculator2, based on ICalculator. The class ICalculator2 has one additional method, negate, that receives no arguments. The effect of negate is to reverse the sign of currentValue. For example, if currentValue is zero, there is no change, if it is -22 then it becomes 22, if it is 100 it becomes -100. Furthermore negate returns the new value of currentValue.
Engineering
1 answer:
shtirl [24]2 years ago
3 0

We connect with computers through coding, often known as computer programming.

<h3>How to code?</h3>
  • We connect with computers through coding, often understood as computer programming.
  • Coding exists similar to writing a set of instructions because it instructs a machine what to do.
  • You can instruct computers what to do or how to behave much more quickly by learning to write code.

class ICalculator {

int currentValue;

int add(int value) {

this.currentValue = currentValue + value;

return currentValue;

}

int sub(int value) {

this.currentValue = currentValue - value;

return currentValue;

}

int mul(int value) {

this.currentValue = currentValue * value;

return currentValue;

}

int div(int value) {

this.currentValue = currentValue / value;

return currentValue;

}

}

public class ICalculator2 extends ICalculator {

int negate() {

if (currentValue != 0)

this.currentValue = -currentValue;

return currentValue;

}

public static void main(String[] args) {

ICalculator2 ic = new ICalculator2();

ic.currentValue=5;

System.out.println(ic.add(2));

System.out.println(ic.sub(5));

System.out.println(ic.mul(3));

System.out.println(ic.div(3));

System.out.println(ic.negate());

}

}

To learn more about code, refer to

brainly.com/question/22654163

#SPJ4

You might be interested in
Select the correct answer.
irina [24]
The answer is C because the word graphic means picture.
4 0
3 years ago
A 2-stage dcv that has an internal pilot does not work well (if at all) on
sp2606 [1]

Answer:

i really font onow why tbh eot you

4 0
3 years ago
What are example for mantle
xenn [34]

The definition of a mantle is a shawl or a cloak. An example of a mantle is a fancy shawl worn over a cocktail dress.

3 0
3 years ago
FASTT PLZZ!!!! -Every person's body is different, _____.
denpristay [2]

Answer:

a

Explanation:

5 0
3 years ago
Read 2 more answers
When Was The First Semi Truck Made?
Verdich [7]
Semi trucks were first made around the 1898 year so I would go with 2. 1890s
5 0
3 years ago
Other questions:
  • Magnesium sulfate has a number of uses, some of which are related to the ability of the anhydrate form to remove water from air
    15·1 answer
  • Consider tests of an unswept wing that spans the wind tunnel and whose airfoil section is NACA 23012. Since the wing model spans
    13·1 answer
  • Write a script (Program 2) to perform t he following matrix operations. Use output commands to clearly output each problem with
    15·1 answer
  • Complete the following sentence.
    7·1 answer
  • Which of the following explains the difference between rangeland management specialists and conservation biologists?
    6·2 answers
  • Which of the following is a possible unit of ultimate tensile strength?
    10·1 answer
  • A _________ is interesting only if the statistics computed from transactions covered by the rule are different than those comput
    14·1 answer
  • An electron is traveling with initial kinetic energy K in a uniform electric field. The electron comes to rest momentarily after
    12·1 answer
  • Engine horsepower decreases ________% for every___________feet above sea level.
    9·1 answer
  • What is the resistance of a resistor if the current flowing through it is 3mA and the voltage across it is 5.3V?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!