diff options
| author | krolxon <krolyxon@tutanota.com> | 2024-02-17 20:45:28 +0530 |
|---|---|---|
| committer | krolxon <krolyxon@tutanota.com> | 2024-02-17 20:45:28 +0530 |
| commit | 36f19c62c2266973818908a10d7962f055714db2 (patch) | |
| tree | 2ca9ac107e458c48e57aed807be1b708d6c1d060 /src/Calculator.java | |
| parent | 6186556a8424a636fd55ef1d5fe4aabebdbe2c49 (diff) | |
add build script
Diffstat (limited to 'src/Calculator.java')
| -rw-r--r-- | src/Calculator.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/Calculator.java b/src/Calculator.java new file mode 100644 index 0000000..c43ca9f --- /dev/null +++ b/src/Calculator.java @@ -0,0 +1,30 @@ +import java.util.Scanner; + +public class Calculator { + public static void main(String[] args) { + // String expr = "(84 / 4 * 3 - 9) * 2 + 1 / 5"; // 108.2 + String expr = new String(" "); + Scanner sc = new Scanner(System.in); + Parser p; + + if (args.length == 0) { + new GFrame("Calculator"); + } else { + if (args[0].equals("-n")) { + System.out.println("Type \"exit\" or Ctrl+C to exit."); + while (true) { + System.out.print(">>> "); + expr = sc.nextLine(); + if (!expr.equals("exit")) { + p = new Parser(expr); + System.out.println(p.eval()); + } else { + sc.close(); + break; + } + } + } else { + } + } + } +} |
