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
Oksi-84 [34.3K]
4 years ago
5

The superclass Calculator contains: a protected double instance variable, accumulator, that contains the current value of the ca

lculator. Write a public subclass CalculatorWithMemory, based on Calculator, a double instance variable, memory, initialized to 0 a method, save, that assigns the value of accumulator to memory a method, recall, that assigns the value of memory to accumulator a method, clearMemory, that assigns zero to memory a method, getMemory, that returns the value stored in memory
Computers and Technology
1 answer:
yawa3891 [41]4 years ago
7 0

Answer:

The following program are written in JAVA Programming Language.

//inherit the Calculator class

public class CalculatorWithMemory extends Calculator {  

   private double memory = 0.0;    //initialize double type variable

   public void save() {   //define function

       memory = accumulator;    

   }

   public void recall() {   //define function

       accumulator = memory;

   }

   public void clearMemory() {   //define function

       memory = 0;     //initialize the value

   }

   public double getMemory() {  

       return memory;    // return the value in "memory" variable

   }

}

Explanation:

Here, we inherit the property of the "Calculator" class.

Then, we define the private double type variable "memory" and assign value 0.0.

Then we set the function "save()" inside it we assign the value of "memory" in "accumulator" and close the function.

Then, we define the function "recall()" inside it we assign the value of "accumulator" in "memory" and close the function.

Then we set the function "clearMemory()" inside it we assign "memory" to 0.

After all, we set the double type function "getMemory()" inside we return the value of the "memory".

You might be interested in
What are three responsibilities of an operating system? please answer quick!!!
Dennis_Churaev [7]
Same here thank you
3 0
3 years ago
Two of the child elements of the page body are a navigation list with the ID #hole_list and an article element containing inform
Archy [21]

Answer:

Please see the attached picture for the complete answer.

Explanation:

4 0
4 years ago
Match the component to its function. resistor inductor capacitor battery transistor This component stores a temporary charge. ar
OlgaM077 [116]

Answer:

1. Capacitor.

2. Inductor.

3. Resistor.

4. Battery.

5. Transistor.

Explanation:

1. <u>Capacitor</u>: this component stores a temporary charge.  

2. <u>Inductor</u>: this component stores electric energy in the form of a magnetic field.

3. <u>Resistor</u>: this component prevents components from overheating.

4. <u>Battery</u>: this component produces electricity by converting chemical energy into electric energy.

5. <u>Transistor</u>: the voltage applied to the base can control the current that flows across the emitter and collector.

6 0
3 years ago
Read 2 more answers
Write a function file that accepts the values of r, a and n as arguments and uses a for loop to return the sum of the first n te
Murrr4er [49]

Given, a = 3, r = 1/2, n = 10

%r is common ratio

%n is number of terms

%a is the first term of the series

Sum = 0;

a = 3;

r = 1/2;

for i = 0 : 1 :  10;

Sum = Sum + a * r ^ i;

end

Sum


7 0
3 years ago
The indent buttons on the home tab allow you to increase or decrease paragraph indenting in increments of ____ inches.
TEA [102]
<span>0.5 inches.
You may also manually set the indentation. In order to do this, click the "Page Layout" tab and enter the desired values in the boxes under "Indent". The indentation of a text is the distance it has from the left margin (when writing from left to right).</span>
3 0
3 years ago
Other questions:
  • Andy designed a web page for a product-oriented industry using CSS properties. He used several HTML tags to create the web page.
    6·1 answer
  • In JAVA, answer the following:
    15·1 answer
  • The Cursor is blinking in a white area on the Screen. This area where text will appear in the ____.
    10·2 answers
  • Please help me I need a help
    13·1 answer
  • Win10如何删除自己添加的环境变量?...............
    8·1 answer
  • I need help converting this to python but i have no idea how to.
    12·1 answer
  • Tip of advice on brainliest.You can copy and paste the question then search it in the search bar because i can guaranty that som
    14·1 answer
  • It is the responsibility of a manager to understand the company’s IT architecture and corresponding infrastructure so that the
    8·1 answer
  • You’ve been hired to help a bank automate their deposit/withdrawal system! Your task is to write a Python program that interacts
    6·1 answer
  • Ransomware as a service has allowed the increase of:.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!