Calculator Application with Library 2.1.2
A simple library for performing basic arithmetic operations with application
Loading...
Searching...
No Matches
Program.cs
Go to the documentation of this file.
1namespace CalculatorApp {
2
10internal class Program {
11 private static int Main(string[] args) {
12 try {
13 string output = args.Length == 0 ? CalculatorLibrary.CalculatorCli.RunDemo() : CalculatorLibrary.CalculatorCli.Run(args);
14 Console.WriteLine(output);
15 return 0;
16 } catch (Exception ex) when (ex is ArgumentException or DivideByZeroException) {
17 Console.Error.WriteLine($"Error: {ex.Message}");
18 return 1;
19 }
20 }
21}
22}
Parses and runs the calculator's command-line arguments.
static string RunDemo()
Runs a small built-in demonstration that exercises every operation once, used when the application is...
static string Run(string[] args)
Parses args as <operation> <a> <b> and returns a line of text describing the result.