d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Inheritance
Add Reply New Topic New Poll
Member
Posts: 8,250
Joined: May 10 2012
Gold: 0.00
Apr 12 2015 01:09pm
I am completing another assignment that's very similar to this assignment, and I was supposed to follow these instructions, and would like someone's rendition of this assignment to help me along in the upcoming task.


-----
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.)

Member
Posts: 8,250
Joined: May 10 2012
Gold: 0.00
Apr 12 2015 03:48pm
I'm offering 55fg for this, if someone minds helping me a bit.

I feel like I have a good grasp on the subject, but was hoping someone knows the proper application for a calc in particular.
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Apr 12 2015 05:34pm
Quote
I am completing another assignment that's very similar to this assignment, and I was supposed to follow these instructions, and would like someone's rendition of this assignment to help me along in the upcoming task.


im unclear what exactly you want help with. post whatever relevant code you have and what your question is.

looks like you already have code for addition/subtraction/multiplication/division. so just mimic their format and do it with the new functions they want.
Member
Posts: 8,250
Joined: May 10 2012
Gold: 0.00
Apr 12 2015 08:08pm
Quote (carteblanche @ Apr 12 2015 07:34pm)
im unclear what exactly you want help with. post whatever relevant code you have and what your question is.

looks like you already have code for addition/subtraction/multiplication/division. so just mimic their format and do it with the new functions they want.


I would like someone to complete this assignment, the way they believe it's supposed to be done as a reference. I have relevant code, but it is not relevant with what I am asking.
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Apr 12 2015 08:42pm
Inb4 minko arrives.
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Apr 12 2015 09:42pm
Quote (AbDuCt @ Apr 12 2015 09:42pm)
Inb4 minko arrives.


it's been awhile since we had robust, maintainable, and generic business application code posted here
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Apr 12 2015 09:59pm
Quote (Eep @ Apr 12 2015 11:42pm)
it's been awhile since we had robust, maintainable, and generic business application code posted here


i think he got sucked into the world of WoW
Member
Posts: 1,995
Joined: Jun 28 2006
Gold: 7.41
Apr 12 2015 10:04pm
Quote (carteblanche @ Apr 12 2015 10:59pm)
i think he got sucked into the world of WoW


Kind of, yea.
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll