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
Question 1 of 40
Novay_Z [31]

Answer:

D. Federal Work-Study

Explanation:

8 0
3 years ago
Sarah has to add a picture from her computer file and add a caption to it. Arrange the steps in a correct sequence.
MatroZZZ [7]

Answer:

-Click insert

-Click picture

-Click from file

-Right click the picture

-Select the desired picture and again click Insert

-Click insert caption

-Write the caption and add it

Explanation:

6 0
3 years ago
Type of malware that is spread when you distribute
vladimir1956 [14]
Trojans, normal viruses, etc. Anything can and could hop on to the files you send depending on the websites and if you don't have a firewall.
3 0
4 years ago
If you found out that your friend was blogging unsafely, which of the following would be a good action to take
emmasim [6.3K]
A is the best and safest answer. you don't want to sound like you are trying to control them or tell them what they should or should not do. <span />
3 0
3 years ago
Read 2 more answers
Which describes an operating system that is multitasking?
tatuchka [14]
The answer is b. because A is using one at a time. C is trying to use 1 at a time.
7 0
4 years ago
Read 2 more answers
Other questions:
  • An ipv4 address in the range 169.254.0.1 through 169.254.255.254 indicates a problem with what type of service
    10·1 answer
  • What are some causes of the number of bytes on the wire exceeding the number of bytes being captured?
    6·2 answers
  • All users on the network have antivirus software; however, several users report that they have what an administrator described a
    10·1 answer
  • The 2 main types of copyright relevant to the recording industry?
    5·2 answers
  • The principal objectives of computer security are to prevent unauthorized users from gaining access to resources, to prevent leg
    11·1 answer
  • What is aperture priority mode? When might you use this mode on a camera? What is depth of field? How can you adjust the depth o
    13·1 answer
  • When using color in a computer - generated presentation aids you should use?
    7·1 answer
  • The elements in a long array of integers are roughly sorted in decreasing order. No more than 5 percent of the elements are out
    12·1 answer
  • can somebody please explain to me why I woke up today to see that all of my 40 answers where deleted ? like what I spent hours
    11·2 answers
  • Write a java code to print Multiplication Table Till 20
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!