I am trying to write a java program (which is part of an assignment) which allows users to input their own function, and then the program calculates it and gets a value. I have actually written a program that calculates an IVP (Initial Value Problem) using the Euler-Cauchy method. My initial function was -2*t*u^2. However, what if I want to work on 4*t*u^3 instead or some other formula?
I tried getting the formula as String from the user, but I am having difficulty in matching a particular variable (e.g. t or u) to a number.