![]() ") Ĭonsole.WriteLine($"This operation is not supported. You could then "map" each enum to a function taking two double values and returning another - that's a Func: var strategies = new Dictionary> Say you had an enum: public enum CalculatorOperation How about you take the concern of creating the menu out of there, find a way to encapsulate each operation into its own strategy object, and generate the menu based on how many available strategies you have? It looks like at one point it was intended to support 4 - Multiply, but the idea was dropped and now 4 is an invalid input despite the instructions at the top saying (1-4), and the instructions at the bottom saying 1-3! I'd actually make that function return a double? (or Nullable, so that the calculator knows the number isn't valid when that function returns a null). Your code is making the assumption that the user will enter a valid double! Look into TryParse, and write a separate function with the sole purpose of turning a string into a double. What happens if you play the QA engineer here? Console.WriteLine ("What is your first number?: ") Your code works when the sky is blue and the user isn't being too clever. The first concern you have, is getting user input. So I'm not going to suggest other ways, instead I'm going to hint at how you could improve the flexibility of what you've got. There are as many ways to write a calculator as there are programmers willing to write one. It’s a simple calculator that allow us to perform all kinds of calculation in Linux command line, which is not pre-installed and you need to use the below commands to install it. I'll blame the extra-weird broken indentation on copy/paste difficulties, and ignore that. Num02 = double.Parse(Console.ReadLine()) Ĭonsole.WriteLine("\nTotal of " num01 " - " num02 " = " (num01 - num02)) Ĭonsole.WriteLine("Division Selected: ") Ĭonsole.WriteLine("\n Total of " num01 " / " num02 " = " (num01 / num02)) Ĭonsole.WriteLine("Sorry, incorrect input") Num02 = double.Parse (Console.ReadLine()) Ĭonsole.WriteLine ("\nTotal of " num01 " " num02 " = " (num01 num02)) Ĭonsole.WriteLine ("Subtract Selected: ") Create an estimate Start your estimate with no commitment, and explore AWS services and pricing for your architecture needs. Configure a cost estimate that fits your unique business or personal needs with AWS products and services. UserChoice = int.Parse (Console.ReadLine ()) Ĭonsole.WriteLine ("\nAddition Selected: ") AWS Pricing Calculator Estimate the cost for your architecture solution. Num01 = double.Parse (Console.ReadLine()) Ĭonsole.WriteLine ("\nPlease select one of the following (1-4)") There are also fun things to try, hardware, free programming books and tutorials, and much more.I'm pretty new to C# and was just wondering if there is a better way I can write this calculator that I made: using System Ĭonsole.WriteLine ("What is your first number?: ") There are hundreds of in-depth reviews, open source alternatives to proprietary software from large corporations like Google, Microsoft, Apple, Adobe, IBM, Cisco, Oracle, and Autodesk. ![]() The software collection forms part of our series of informative articles for Linux enthusiasts. Our curated compilation covers all categories of software. Read our complete collection of recommended free and open source software. Multifunctional scientific graphic calculator High precision and powerful desktop calculator High precision scientific calculator supporting physical units Powerful and easy to use multi-purpose cross-platform desktop calculatorĭesktop calculator, an educational tool in mathematics, and for research For each title we have compiled its own portal page, providing a screenshot of the software in action, a full description with an in-depth analysis of its features, together with links to relevant resources. Let’s explore the 10 calculator tools at hand. Here’s our verdict of the featured calculators. ![]() Hopefully, there will be something of interest for anyone who wants more functionality offered by simple calculators. Using MEF, you will be able to add new operators without changing the application code. To provide an insight into the quality of software that is available, we have compiled a list of 8 high quality Linux calculator tools. The goal of SimpleCalculator is to create a console application that accepts basic arithmetic commands, in the form '5 3' or '6-2', and returns the correct answers. Rest assured, the calculators listed below are of precision quality. ![]() The classic example being the calculator shipped with Windows 3.1 which could not even reliably subtract two numbers. Occasionally, the calculator tool provided with an operating system did not engender any confidence. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |