r/programminghelp • u/i_do_jokes • Jul 14 '20
Java A question about Java
So in java you can make calculations like 3+1 now my question is if i ask for input lets say in a calculator and the second string is + (the first one would be 3 and the third one would be 1) how can i convert the + from a string into a symbol that i can make calculations with
4
Upvotes
2
u/[deleted] Jul 14 '20
You'll have to use an if statement or a switch statement to check the second string, if it's a plus sign "+" then you'll perform addition on the two other strings (After converting them to integers, etc).