You should put a breakpoint at the beginning of your
mathTheStack
method and launch a debug session; this will allow you to check the three stacks and to understand why the line 32 of the BiggerStackProject.java file causes the exception to be thrown.
Quickly checking your algorithm, I think this part may be of interest:
for(int x = 0; x < input.size(); x++){
if(input.peek() == "*" || input.peek() == "/" || input.peek() == "%"){
operators.push(input.pop());
}
else{
if(operators.pop().equals("*")){
On the first iteration (x = 0), if the first character is a digit, the else block is executed. At this point, you did not push anything into the operators stack yet, and you try to pop from it, which throws the exception.
There are several ways to do what you are trying to achieve, but one of the first things you could try is to qualify both numbers and operators stacks first, before trying to use them. You only qualified the numbers stack in your first loop, so maybe you could rework this loop to qualify both stacks?
As a side note, why do you handle numbers as strings?
Stack
class is generic, meaning you can use a
Stack<double>
as well.