import java.util.Stack;

public class OperandTest {
	static Operand op;
	static Stack st;
	
	public static void main(String [] argv){
		op = new Operand();
		st = new Stack();

		op.addDigit('1');
		op.addDigit('2');
		op.addDigit('9');
		op.deleteLastDigit();
		op.addDigit('3');		
		op.complete();

		System.out.println(OperandTest.st.pop());

		op.addDigit('9');
		op.addDigit('8');
		op.addDigit('7');
		op.complete();
		System.out.println(OperandTest.st.pop());		
		}
	}
	

class Operand{
	public StringBuffer buf;

	public Operand(){ 
		buf = new StringBuffer(14); 
		}

	public void addDigit(char ch){
		buf.append(ch);
		}  

	public void deleteLastDigit(){
		String s =new String(buf);
		buf = new 
StringBuffer(s.substring(0,s.length()-1));
		}
	
	public void reset(){
		buf = new StringBuffer(14);
		}	 

	public void set(double val){ 
		reset();
		buf.append(val);
		}

	public void complete(){      
		Double d = new Double(buf.toString());
		OperandTest.st.push(d);
		}
	}
