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
. (20 pts) A horizontal cylindrical pipe (k = 10 W/m·K) has an outer diameter of 15 cm and a wall thickness of 5 cm. The pipe is
nata0808 [166]

Answer:

Check the explanation

Explanation:

Kindly check the attached image below to see the step by step explanation to the question above.

7 0
3 years ago
The type of current that flows from the electrode across the arc to the work is called what?
Scrat [10]

Answer:

Direct current.

Explanation:

5 0
3 years ago
What are the horizontal structures beneath a slab that help transfer the load from the slab to the columns?
Delicious77 [7]

Answer: D) Beams

Explanation:

3 0
2 years ago
Read 2 more answers
One gram of Strontium-90 has an activity of 5.3 terabecquerels (TBq), what will be the activity of 1 microgram?
noname [10]

1 micro gram of Strontium-90 has an activity of

0.0000053 terabecquerels (TBq),

Explanation:

Given information denotes that .,one gram of Strontium-90 has an activity of 5.3 terabecquerels (TBq)

the activity of 1 micro gram is

1 gram = 1,000,000 micro gram has activities of 5.3 terabecquerels

therefore 1 micro gram has the activity of (5.3 ÷  1,000,000 = 0.0000053 )

= (5.3 ÷  1,000,000 = 0.0000053 )

Hence ., 1 micro gram of Strontium-90 has an activity of

0.0000053 terabecquerels (TBq),

8 0
3 years ago
Write a program that uses the function isPalindrome given below. Test your program on the following strings: madam, abba, 22, 67
defon

Answer:

#include <iostream>

#include <string>

using namespace std;

bool isPalindrome(string str)

{

   int length = str.length();

   for (int i = 0; i < length / 2; i++)

   {

       if (tolower(str[i]) != tolower(str[length - 1 - i]))

           return false;

   }

   return true;

}

int main()

{

   string s[6] = {"madam", "abba", "22", "67876", "444244", "trymeuemyrt"};

   int i;

   for(i=0; i<6; i++)

   {

       //Testing function

       if(isPalindrome(s[i]))

       {

           cout << "\n " << s[i] << " is a palindrome... \n";

       }

       else

       {

           cout << "\n " << s[i] << " is not a palindrome... \n";

       }

   }    

       

   return 0;

}

5 0
3 years ago
Other questions:
  • An air conditioner using refrigerant R-134a as the working fluid and operating on the ideal vapor-compression refrigeration cycl
    12·1 answer
  • Given the unity feedback system
    5·1 answer
  • A(n)______ is a device used to ensure positive position of a valve or damper actuator A. calibrator B. positioner C. actuator D.
    6·1 answer
  • For problems 1 and 2, six luminaires, similar to Style E used in the Commercial Building, are to be installed in a room that is
    13·1 answer
  • What is torque and how does it work?
    14·2 answers
  • Are you able to text without looking at your phone?
    10·1 answer
  • If you play roblox leave user down bellow
    14·2 answers
  • Employees cannot be held legally responsible for an environmental violation.
    14·1 answer
  • Which is the correct way of dual dimensioning using the position method
    7·1 answer
  • If an internally piloted DCV does not shift, you should use a gauge to _____. A.check the pilot line pressure b. check the inlet
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!