Created
September 13, 2020 07:51
-
-
Save gaufung/803d6675be9515aeba9175ed81b00012 to your computer and use it in GitHub Desktop.
Calculator prototype
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // program.cs | |
| static void Main(string[] args) | |
| { | |
| const string WELCOME = "Welcome to Calculator. Feel free to type any expression you want."; | |
| const string PROMPT = ">> "; | |
| Console.Out.Write(WELCOME + Environment.NewLine); | |
| while(true) | |
| { | |
| Console.Out.Write(PROMPT); | |
| try | |
| { | |
| var input = Console.In.ReadLine(); | |
| if(string.Compare(input, "exit", StringComparison.OrdinalIgnoreCase) == 0) | |
| { | |
| break; | |
| } | |
| Console.Out.Write(input); | |
| Console.Out.Write(Environment.NewLine); | |
| } | |
| catch(Exception e) | |
| { | |
| Console.Out.Write("Oops! Something seems to go wrong." + Environment.NewLine); | |
| Console.Out.Write(e.Message); | |
| Console.Out.Write(Environment.NewLine); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment