We will create a program to add and subtract arbitrarily large integers. This program will be performed in two different ways. When your program starts, it will accept two strings of numbers (large integers - possibly with a minus sign) from the user, separated by either a (+) or (-) sign. Your program will then either add them together or subtract them. This will be done with the following approach:
1. Pad the shorter string with "0" characters on the left. You might want to pad the longer string also, to remove any special case with the high-order digits.
2. Push all the characters, one at a time, onto separate stacks, starting at the high-order digits (the left-hand side of the string). This will result in the low-order digits at the top of each of the two stacks.
3. Repeat: Pop the characters off one at a time from each stack, perform the appropriate operation, and push the resulting character onto a third stack. Set a carry (if adding) or a borrow (if subtracting) if necessary for inclusion in the next items. Repeat this until done.
4. Pop the characters off the result stack and concatenate into a String. Display the string in order to display the result.
Note that you might come out with a negative result. You must account for this possibility and place the minus at the start of your answer.
The two ways to implement this program will come from the fact that we will use two different versions of stacks for this project:
When your programs run, they should read a file named "addsAndSubtracts.txt." The programs should show each expression to be evaluated and the answer for each expression in the file.
Both your programs should have identical interfaces. Your program that adds and subtracts the numbers should run identically regardless of whether it is using the stack you create with java.util.LinkedList or the one you create with your own linked stack.
Notes