Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA Write a program that uses the class Calculator in Listing 9.12 to create a more powerful calculator. This calculator will allow you to save

JAVA

Write a program that uses the class Calculator in Listing 9.12 to create a more powerful calculator. This calculator will allow you to save one result in memory and call the result back. The commands the calculator takes are

e for end

c for clear; sets result to zero

m for save in memory; sets memory equal to result

r for recall memory; displays the value of memory but does not change result

You should define a derived class of the class Calculator that has one more instance variable for the memory, a new main method that runs the improved calculator, a redefinition of the method handleUnknownOpException, and anything else new or redefined that you need. A sample interaction with the user is shown next. Your program need not produce identical output, but it should be similar and just as clear or even clearer.

Calculator on: result = 0.0 + 4 result + 4.0 = 4.0 updated result = 4.0 / 2 result / 2.0 = 2.0 updated result = 2.0 m result saved in memory c result = 0.0 + 99 result + 99.0 = 99.0 updated result = 99.0 / 3 result / 3.0 = 33.0 updated result = 33.0 r recalled memory value = 2.0 result = 33.0 + 2 result + 2.0 = 35.0 updated result = 35.0 e End of program

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Visual Basic 6 Databases

Authors: Charles Williams

1st Edition

1861002025, 978-1861002020

More Books

Students also viewed these Databases questions

Question

What is electric dipole explain with example

Answered: 1 week ago

Question

What is polarization? Describe it with examples.

Answered: 1 week ago

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago