Task: Create a table of values of the function y = f (x) on the interval [n; m] with step k
Actually the question arises in the moment. How to enter f (x). For the formula itself (for example, x-2) is a string, and the value of Y is a number. those. Through the scanner enter all the values of n, m, k and the formula "x-2" or any other. And in the code, this formula is used to calculate the value of Y.
while(x<=rm){ y=x-5; System.out.println("x = " +x+" y = "+ y); x=x+rk; } In this case, I have a formula entered initially "y = x-5" (second line, entered clumsily, directly into the code), and I need the program to read the one that I enter through the scanner.
upd. After a large number of read and tested, I want to add that entered through the scanner is Tsislov values, the letter X and the signs of arithmetic calculations ("+", "-", "/", "*").