aboutsummaryrefslogtreecommitdiff
path: root/Calculator.java
diff options
context:
space:
mode:
Diffstat (limited to 'Calculator.java')
-rw-r--r--Calculator.java8
1 files changed, 7 insertions, 1 deletions
diff --git a/Calculator.java b/Calculator.java
index 031fa57..43804c3 100644
--- a/Calculator.java
+++ b/Calculator.java
@@ -1,8 +1,14 @@
public class Calculator {
public static void main(String[] args) {
String expr = "(84 / 4 * 3 - 9) * 2 + 1 / 5"; // 108.2
- Parser p = new Parser(expr);
+ Parser p;
+ if (args.length == 0) {
+ p = new Parser(expr);
+ } else {
+ p = new Parser(args[0]);
+ }
String postfix = p.toPostFix();
+ // System.out.println("pfix => \t " + postfix);
System.out.println(p.evalExpr(postfix));
}
}