Answered step by step
Verified Expert Solution
Question
1 Approved Answer
How to make the program (static nested Class) Create a class Calculator, which represents a regular scientific calculator. It should have an instance variable history,
How to make the program (static nested Class)
Create a class Calculator, which represents a regular scientific calculator. It should have an instance variable history, which is a list of objects of type Calculation, representing the history of calculations done. It should also have a method clear()), which empties the history. It should also have a calculate instance method which expects one argument of type Calculation, and adds the given argument to its history. Finally, Calculator should have a toString(), which prints out the history of calculations in a nice way. Create a static nested class Calculation, which for this example is nothing more than a wrapper for a String. So, it should have an instance variable text of type String that represents what the line of text for this Calculation is (for example, "5 + 10"). Then, in your main method, create multiple calculators, multiple calculations, and practice adding them to calculators, printing the calculators, and clearing.
Step by Step Solution
★★★★★
3.55 Rating (152 Votes )
There are 3 Steps involved in it
Step: 1
Below is an example implementation in Java with a static nested class Calculation and the Calculator ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started