-4

How do I make a method that receives from the user a Mathematical function represented by (x) like (x + 2), then receives a number which is (x) .. then return the result !! ..

Cœur
  • 37,241
  • 25
  • 195
  • 267

2 Answers2

0

Here's a link that gives a example on how to implement the shunting yard algorithm for expression parsing: https://eddmann.com/posts/shunting-yard-implementation-in-java/

You can use the ideas in this to build your expression parser and read the stack of commands using switch statements to perform the operation entered. Good luck on the project!

Tim Hunter
  • 242
  • 1
  • 7
-2

If you mean what i think you do, you just need to make a function with a parameter, do the calculation and return the result.