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
atroni [7]
3 years ago
12

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 calculatora getter method for the above instance variablemethods add, sub, mul, and divEach 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.
Computers and Technology
1 answer:
Over [174]3 years ago
7 0

Answer:

Explanation to the approach and code given below

Explanation:

I am considering that you need only a defined subclass and not the working program.

So given statement is,  

The class  ICalculator 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.

Here is the code:

public class ICalculator1 extends ICalculator {

       public int sign() {

         if (currentValue != 0) {

           return currentValue * -1;}

         else {

           return 0;  

           }

       }

   }

or you can try this alternative soluton.

public int sign() {

  int value = add(0);   // add 0 and return currentValue

  if (value > 0) return 1;

  else if (value < 0) return -1;

  else return 0;

}

You might be interested in
The statements in the body of a while loop may never be executed, whereas the statements in the body of a do-while loop will be
LenKa [72]

Answer:

a. at least once

Explanation:

A loop is a code snippet that uses a condition to run repeatedly for multiple times which could be zero, one or more times. As long as the condition is true, the loop statement executes over and over again. Three common types of loop are;

i. for loop

ii. while loop

iii. do while loop

In a for or while loop, the condition for the loop is first tested before the statements in the loop are executed. Statements in the body of the loop are executed zero or more times. i.e the loop statement (statement in the body of the loop) may or may not be executed.

In a do..while loop, the statements in the loop are executed first before the condition of the loop is tested. In this case, the statements in the body of the loop are executed one or more times. i.e the loop statement is executed at least once.

6 0
3 years ago
When you copy a formula that contains an absolute reference to a new location, the reference ____.
iVinArrow [24]

When you copy a formula that contains an absolute reference to a new location, the reference remain constant . Relative references change when a formula is duplicated to another cell. Unlimited references, on the different hand, remain constant no matter where they are copied.

<h3>What stays constant in life?</h3>
  • One constant since the start of time might be switching, however, the fear of change is also a constant.
  • Since times immemorial, humans have liked routine. It makes us feel in command of our lives.
  • Some common synonyms of regular are faithful, loyal, resolute, staunch, and steadfast.
  • While all these words mean "firm in adherence to whatever one owes loyalty," they constantly pressure continuing firmness of emotional passion without necessarily meaning strict obedience to contracts or vows.

To learn more about  remain constant , refer to :

brainly.com/question/24868934

#SPJ4

4 0
2 years ago
What role does Dan Carson play at Hornall Anderson Design Works?
ANEK [815]
<span>Head of Design 

Hope this helps ;)</span>
8 0
3 years ago
The success of Eye of the Storm exemplifies:
lyudmila [28]
A should be correct i think
6 0
3 years ago
Read 2 more answers
What is adware?
Mila [183]

Software that, while purporting to serve some useful function and often fulfilling that function, also allows Internet advertisers to display advertisements without the consent of the computer user.

7 0
3 years ago
Other questions:
  • What is Gamekit Loa3's all questsions
    14·1 answer
  • True/False
    11·1 answer
  • g You need to build a circuit to perform parallel data transfers from one set of registers to another. The interconnections betw
    6·2 answers
  • An application server is used to communicate between a Web server and an organization's back-end systems.
    6·1 answer
  • True or False. A modern programming EXE provides a text editor, a file manager, a compiler, a linker and loader, and tools for d
    9·1 answer
  • A DBMS makes the: a. relational database available for different analytical views. b. physical database available for different
    12·1 answer
  • In a display device, response rate is the time it takes for one pixel to change from black to white then back to black.​
    12·1 answer
  • Which of the following is NOT areserved word in Java?intpublicstaticnum
    9·1 answer
  • Write. A program to fine the difference of two number 25 and 17 . Also displays the output
    15·1 answer
  • how does the use of data abstraction manage complexity in program code? how does using lists make a program easier to develop an
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!