Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Java (http://www.go4expert.com/forums/java/)
-   -   Why don't I see any output from my program? (http://www.go4expert.com/forums/dont-i-output-program-t27610/)

rickjames8710 16Jan2012 01:26

Why don't I see any output from my program?
 
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());       


}


}


Scripting 17Jan2012 23:44

Re: Why don't I see any output from my program?
 
Did you compiled it as console App ?


All times are GMT +5.5. The time now is 14:38.