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]
3 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]3 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
Can someone plss help me!!
REY [17]

Answer:

HTML elements are delineated by tags, written using angle brackets.

Explanation:

Tags such as <img /> and <input /> directly introduce content into the page.

8 0
2 years ago
What is one purpose of an algorithm
adelina 88 [10]

Answer:

Algorithms is formula for solving a problem. It is helpful because it specifically give instructions detail to computer to what a computer should perform a specific task.

For e.g. calculating report cards.

4 0
3 years ago
Put the following events from computer history in the order they happened:
kykrilka [37]
Show us a picture so we can answer
7 0
3 years ago
The ____ tag is used to bring an image into a website. <br> (I need the blank for tag)
Montano1993 [528]
The *image* tag is used to bring an image on the website.
4 0
3 years ago
Read 2 more answers
___________ are the constant values that are used in a program. ​
77julia77 [94]

Answer: Data

Explanation:

3 0
3 years ago
Other questions:
  • Describe in 2–3 sentences how you would use the autosum shortcut.
    9·2 answers
  • MD5 uses a hash value to create a hash which is typically a 32 character hex number and how many bits?
    11·1 answer
  • 3. What type of error is in the following sentence? "George W. Bush is the President of the United States of
    5·1 answer
  • The presentation ____ determines the formatting characteristics of fonts and colors.
    11·2 answers
  • Python: Write a program that generates 8 random scores (between 0 and 100), store them in an array,
    8·1 answer
  • A contracting company recently completed it's period of performance on a government contract and would like to destroy all infor
    13·1 answer
  • A web application is an example of:
    7·1 answer
  • List five applications field of a computer?​
    8·1 answer
  • Delete temp or %temp% files in Windows 10 is safe and, can it help boost up your PC fps?
    5·1 answer
  • 7 TH GRADE QUESTION...PLS HELP
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!