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]
1 year 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]1 year 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
A remote village on an island was devastated by a typhoon. Farmland was flooded and the crops
insens350 [35]

Answer:

A flood happens when water overflows or soaks land that is normally dry. flooding, happens when a large storm or tsunami causes the sea to They soon fell ill and died from cholera, which is spread by  Rice, wheat, and corn crops were destroyed.  Excess water overflows and runs on top of the land.

Explanation:

hope this helps

6 0
3 years ago
Nêu đặc điểm của tín hiệu PAM rời rạc dạng lưỡng cực NRZ, RZ
zhuklara [117]

Answer:

yes it is certainly good ice cream

4 0
3 years ago
Takt time is the rate at which a factory must produce to satisfy the customer's demand. a)- True b)- False
laila [671]

Answer: a)True

Explanation: Takt time is defined as the average time difference between  the production of the two consecutive unit of goods by the manufacturer and this rate is matched with the demand of the customer. This is the time which is calculated to find the acceptable time for which the goods unit must be produced  by the factory to meet the needs of the customer. Therefore , the statement is true that takt time is the rate at which a factory must produce to satisfy the customer's demand.

6 0
3 years ago
What's the highest grade level that brainly accomodates
taurus [48]

Answer:

The highest grade level is college.

3 0
2 years ago
Two small balls A and B with masses 2m and m respectively are released from rest at a height h above the ground. Neglecting air
statuscvo [17]

Answer:

The kinetic energy of A is twice the kinetic energy of B

Explanation:

5 0
3 years ago
Other questions:
  • A 3-kg block rests on top of a 2-kg block supported by, but not attached to, a spring of constant 40 N/m. The upper block is sud
    14·2 answers
  • What kind of value should an employee possess when employees are expected to be responsible and fair?
    5·1 answer
  • What is the base unit in standard measurement
    13·2 answers
  • Hii I need help can someone help me
    15·1 answer
  • A heat engine operates between a source at 477°C and a sink at 27°C. If heat is supplied to the heat engine at a steady rate of
    14·1 answer
  • Place these events in chronological order. Put the numbers 1-6 next to the<br> events.
    15·1 answer
  • Which of the following explains why trucking is the most widely used transportation method?
    14·1 answer
  • प्रहार का समरूपी भिन्नार्थक शब्द अर्थ के साथ ​
    10·1 answer
  • The design-bid-build model is prons to abuse because separation of phases facilitates the hiding of corrupt practices.
    7·2 answers
  • How to clean a snowblower carburetor without removing it.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!