Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Memory Calculator To Text File Output This week we will write modify the memory calculator from 06. Sixth Assignment Memory Calculator (Here is the link

Memory Calculator To Text File Output

This week we will write modify the memory calculator from 06. Sixth Assignment Memory Calculator (Here is the link for that: https://paste.ofcode.org/fcNhKzzJ9A8jXEZhpVM6MK ) to be able to save all of the calculations done to a file. There are multiple ways to do this, but I suggest creating an ArrayList of String objects. Each time the user performs an operation (add, subtract, multiply, divide, or clear), add a new String. For instance, if the current value is 6 and the user chooses to add 2, you would create a new String 6 + 2 = 8 and add that String to the ArrayList. You will also need to add a new Save item to the menu. When the user chooses this option, you should call a method that displays a JFileChooser dialog to the user, allow them to select where to save the data, and then write all of the strings from the ArrayList to that file. Be sure to handle exceptions gracefully.

Sample output:

The current value is 0.0

Menu

1. Add

2. Subtract

3. Multiply

4. Divide

5. Clear

6. Save

7. Quit

What would you like to do? 1

What is the second number?

5

The current value is 5.0

Menu

1. Add

2. Subtract

3. Multiply

4. Divide

5. Clear

6. Save

7. Quit

What would you like to do? 2

What is the second number?

3

The current value is 2.0

Menu

1. Add

2. Subtract

3. Multiply

4. Divide

5. Clear

6. Save

7. Quit

What would you like to do? 3

What is the second number?

5

The current value is 10.0

Menu

1. Add

2. Subtract

3. Multiply

4. Divide

5. Clear

6. Save

7. Quit

What would you like to do? 4

What is the second number?

0

The current value is NaN

Menu

1. Add

2. Subtract

3. Multiply

4. Divide

5. Clear

6. Save

7. Quit

What would you like to do? 5

The current value is 0.0

Menu

1. Add

2. Subtract

3. Multiply

4. Divide

5. Clear

6. Save

7. Quit

What would you like to do? 6

The current value is 0.0

Menu

1. Add

2. Subtract

3. Multiply

4. Divide

5. Clear

6. Save

7. Quit

What would you like to do? 7

Goodbye!

The data in the file should look

like this:

Initial value is 0

0.0 + 5.0 = 5.0

5.0 - 3.0 = 2.0

2.0 * 5.0 = 10.0

10.0 / 0.0 = NaN

Cleared

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

Sams Teach Yourself Beginning Databases In 24 Hours

Authors: Ryan Stephens, Ron Plew

1st Edition

067232492X, 978-0672324925

Students also viewed these Databases questions

Question

What was the positive value of Max Weber's model of "bureaucracy?"

Answered: 1 week ago