0
Java calculator
Hello im new in java.i need a method for my calculator to make more than 2 action.not just firstnumber+secondnumber?please help me!thnx
3 Respostas
+ 1
You could solve this by recursion.
Or iterate over all actions you wanna take.
Also some more advanced topics for a calculator would be to look into reverse polish notation.
+ 1
You can pass the expression as a whole string then split it to an array, then perform the operation depending on the operator using a switch statement ..
For example you pass "3 * 2", when you split it it's "3", "*", "2", arr[1] is "*", so you perform multiplication.