Write a subclass of the memorycalc class from assignment 6


Assignment

In this assignment, you will write a subclass of the MemoryCalc class from Assignment 6. This new calculator, called ScientificMemCalc, should be able to do everything that the MemoryCalc could do, plus raise the current value to a power and compute the natural logarithm of the current value. This is a fairly realistic assignment - often when you are working for a company, you will be asked to make minor extensions to existing code.

You will need to override the displayMenu method to add the new options. Be sure to only add code to the ScientificMemCalc class if it is necessary - leverage the code from the base MemoryCalc class whenever possible. Use the power of inheritance to do this rather than cutting and pasting or otherwise duplicating the code. Finally, write a new class called ScientificCalcDriver that shows the functionality of your new class. This will be very similar to the CalcDriver class contained in the assignment9.jar file.

Sample output:
The current value is 0.0 Menu
1. Add
2. Subtract
3. Multiply
4. Divide
5. Power
6. Logarithm
7. Clear
8. Quit

What would you like to do? 1 What is the second number? 20 The current value is 20.0

Menu
1. Add
2. Subtract
3. Multiply
4. Divide
5. Power
6. Logarithm
7. Clear
8. Quit

What would you like to do? 2 What is the second number? 10 The current value is 10.0

Menu
1. Add
2. Subtract
3. Multiply
4. Divide
5. Power
6. Logarithm
7. Clear
8. Quit

What would you like to do? 3 What is the second number? 3 The current value is 30.0

Menu
1. Add
2. Subtract
3. Multiply
4. Divide
5. Power
6. Logarithm
7. Clear
8. Quit

What would you like to do? 4 What is the second number? 6 The current value is 5.0

Menu
1. Add
2. Subtract
3. Multiply
4. Divide
5. Power
6. Logarithm
7. Clear
8. Quit

What would you like to do? 5 What is the second number? 2 The current value is 25.0

Menu
1. Add
2. Subtract
3. Multiply
4. Divide
5. Power
6. Logarithm
7. Clear
8. Quit

What would you like to do? 6
The current value is 3.2188758248682006

Menu
1. Add
2. Subtract
3. Multiply
4. Divide
5. Power
6. Logarithm
7. Clear
8. Quit

What would you like to do? 7 The current value is 0.0

Menu
1. Add
2. Subtract
3. Multiply
4. Divide
5. Power
6. Logarithm
7. Clear
8. Quit

What would you like to do? 8

Goodbye!

You will be graded according to the following rubric (each item is worth one point):

- The ScientificMemCalc class is a subclass of MemoryCalc
- The scientific calculator can do everything that the memory calculator can do
- The scientific calculator can raise the current value to a power and find the natural logarithm of the current value (hint: use Math.pow and Math.log)
- Your driver program allows a user to try all of the functionality in the scientific calculator
- No code from MemCalc is unnecessarily duplicated in ScientificMemCalc
- You have followed the principle of encapsulation. In particular, the currentValue field in the MemCalc class is private.
- Your program produces correct output for all inputs
- Your program compiles
- Your program runs
- You follow standard coding conventions (e.g. variable names, indentation, comments, etc.)

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Write a subclass of the memorycalc class from assignment 6
Reference No:- TGS02383151

Now Priced at $15 (50% Discount)

Recommended (99%)

Rated (4.3/5)