Question: 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

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

1 Expert Approved Answer
Step: 1 Unlock

Below is an example implementation in Java with a static nested class Calculation and the Calculator ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!