Nenad
~Choco Coronet~ Omnomnom
- Reaction score
- 137
I'm using eclipse with acm.jar and i can't seem to print out my stack of objects, here's the code:
If i add a ; on the if statement i am able to print out my stack but i need it to work without the ; since i can't do anything after this.
The boolean variables just check wheter or not a string is a digit or an operator (+-/*).
Simply put, i want to print out the stack every time i add or change something in it (for every loop count, the stack needs to be printed out in the end).
Code:
public void run () {
int i = 1;
Stack Number = new Stack();
while(i!=0)
{
String oper = readLine("Enter Number or Operator: ");
boolean Digit = checkForDigit(oper);
boolean Operator = checkForOperator(oper);
if (Digit==true)
{
double number = Double.parseDouble(oper);
Number.push(number);
println(Number);
}
}
}
If i add a ; on the if statement i am able to print out my stack but i need it to work without the ; since i can't do anything after this.
The boolean variables just check wheter or not a string is a digit or an operator (+-/*).
Simply put, i want to print out the stack every time i add or change something in it (for every loop count, the stack needs to be printed out in the end).