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
Many experts consider Coding a language?<br><br> true or false
VladimirAG [237]

Answer:

True

Explanation:

Coding is a language because it takes time and practice to learn and do it. If you don't practice it, you could put the wrong thing into code and have everything go bonkers.

Hope this helps!! :)

6 0
2 years ago
Read 2 more answers
6.32 LAB: Exact change - functions
Neko [114]

Answer:

Below is the desired C++ program for the problem. Do feel free to edit it according to your preference

Explanation:

#include <iostream>

#include <vector>

using namespace std;

void ExactChange(int userTotal, vector<int> &coinVals) {

   coinVals.reserve(5);

   coinVals[0] = userTotal / 100;

   userTotal %= 100;

   coinVals[1] = userTotal / 25;

   userTotal %= 25;

   coinVals[2] = userTotal / 10;

   userTotal %= 10;

   coinVals[3] = userTotal / 5;

   userTotal %= 5;

   coinVals[4] = userTotal;

}

int main() {

   vector<int> coins;

   int value;

   cin >> value;

   if (value <= 0) {

       cout << "no change" << endl;

   } else {

       ExactChange(value, coins);

       if (coins[0] != 0) cout << coins[0] << " " << (coins[0] == 1 ? "dollar" : "dollars") << endl;

       if (coins[1] != 0) cout << coins[1] << " " << (coins[1] == 1 ? "quarter" : "quarters") << endl;

       if (coins[2] != 0) cout << coins[2] << " " << (coins[2] == 1 ? "dime" : "dimes") << endl;

       if (coins[3] != 0) cout << coins[3] << " " << (coins[3] == 1 ? "nickel" : "nickels") << endl;

       if (coins[4] != 0) cout << coins[4] << " " << (coins[4] == 1 ? "penny" : "pennies") << endl;

   }

   return 0;

}

5 0
3 years ago
What are the three categories of tools?
noname [10]

Answer:

1.      Low power hand tools/small

2.     Light to medium industrial tools

3.     Large industrial tools

There are definitely a lot more categories than three, but this is what I have.

6 0
2 years ago
Failsafing refers to building safeguards into a process to reduce or eliminate the potential for errors during a process. What i
Ksivusya [100]

Answer:

poka-yoke

Explanation:

The term 'poka-yoke' derives its meaning from Japanese language. In Japanese 'poke' means "mistakes" and 'yokeru' means " to avoid ". This ' poka yoke' means to avoid mistakes.

In any process, it is a mechanism that that helps an operator of any equipment to avoid any kind of mistakes while working. It is to prevent the defects in the products by correcting, addressing and preventing any human errors.

It is failsafing which eliminates any kind of potential errors in a process.

4 0
3 years ago
Jackson Water Department wants a program that calculates a customer's monthly water bill. The clerk will enter the current and p
valentinak56 [21]

Answer:

See attached images

Explanation:

See attached images

Hope this helps!

4 0
3 years ago
Other questions:
  • LUNES MARTES MIÉRCOLES JUEVES VIERNES SÁBADO DOMINGO
    10·1 answer
  • What type of models can be communicated in more than one way.
    12·1 answer
  • What can happen to you if you are in a crash and not wearing a seat belt?<br> Explain.
    13·2 answers
  • What is the definition of a tolerance on a dimension typically found on technical drawings?
    7·1 answer
  • The water level in a large tank is maintained at height H above the surrounding level terrain. A rounded nozzle placed in the si
    9·1 answer
  • Steam enters a turbine steadily at 7 MPa and 600°C with a velocity of 60 m/s and leaves at 25 kPa with a quality of 95 percent.
    14·1 answer
  • Define a separate subroutine for each of the following tasks respectively.
    6·2 answers
  • How would you design a wheelchair for wheelchair-using basketball players? Would you make it more or less massive?
    11·1 answer
  • Which of the following uses pressure and flow to transmit power from one location to another?
    11·1 answer
  • The ______ number of a flow is defined as the ratio of the speed of flow to the speed of sound in the flowing fluid.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!