Why don't I see any output from my program?

rickjames8710's Avatar, Join Date: Jan 2012
Newbie Member
I tried compiling this program several times but did't see any output. Could anyone give me any suggestion on why I'm not seeing any output when I run this code.
Code:
//import java.io.*;
//import java.math.*;
//import java.io.OutputStreamWriter;
import java.io.BufferedInputStream;
//import java.lang.*;
import java.util.*;
import java.util.Scanner;
//import java.io.PrintWriter;
//import java.io.UnsupportedEncodingException;
//import java.util.Locale;


public class StdIn {

private static Scanner scanner = new Scanner(new BufferedInputStream(System.in));


public static boolean isEmpty() 
{ return !scanner.hasNext();}


public static String readString() 
{ return scanner.next();}



public static void main (String args[]){ 


Stack<String> ops = new Stack<String>();

Stack<Double> vals = new Stack<Double>();



while (!StdIn.isEmpty())
{ // Read token, push if operator.
String s = StdIn.readString();
if (s.equals("(")) ;
else if (s.equals("+")) ops.push(s);
else if (s.equals("-")) ops.push(s);
else if (s.equals("*")) ops.push(s);
else if (s.equals("/")) ops.push(s);
else if (s.equals("sqrt")) ops.push(s);
else if (s.equals(")"))

{ // Pop, evaluate, and push result if token is ")".
String op = ops.pop();
double v = vals.pop();
if (op.equals("+")) v = vals.pop() + v;
else if (op.equals("-")) v = vals.pop() - v;
else if (op.equals("*")) v = vals.pop() * v;
else if (op.equals("/")) v = vals.pop() / v;
else if (op.equals("sqrt")) v = Math.sqrt(v);
vals.push(v);
System.out.println(vals.push(v));
} // Token not operator or paren: push double value.
else vals.push(Double.parseDouble(s));
System.out.println(Double.parseDouble(s));

}
System.out.println(vals.pop());	


}


}

Last edited by shabbir; 16Jan2012 at 08:50.. Reason: Code blocks
0
Scripting's Avatar, Join Date: Jun 2010
John Hoder
Did you compiled it as console App ?