- ImplementingImplement something that works on simple binary operations.
- Extend itImplement something to parse out those operations from string form.
- Add in dialogue to interface with the user.
- Take in command line arguments.
ExceedinglyA Simple example that illustrates all 4 of the above:
For now, you can think of an enumeration as a useful way to store related series of values that won't change. A calculator is a good opportunity to look into them rather than referencing the values directly, and if you're curious there's an interesting way we can apply them to the purpose of a calculator.
Then the calculator program itself.
Notice that I optionally directly accept argument which is something desirable for a CLI. This example has a lot you can still improve on, including input validation and a more direct utilization of the enumeration among other things.
If you're unfamiliar with the split function I'm simply converting whatever the user gives us to a String array, with the indexes separated by spaces (what the regex "\s++" means). so I may treat it as if it was invoked from the command line.
This example has a lot If you can still improve on, including input validation and awant to learn more direct utilization of the enumeration amongabout Regex, you can check out other things.
Notice that I optionally directly accept argument which is something desirable for a CLIpatterns or use HackerRank's decent introduction/practice platform here.