how to write the math function f(x) with Java
where f(x) = y

you may want to
1. check the Math class and see if there's anything in there that can help you
2. if it doesn't try to write a method yourself
3. if you can't figure out what the code should be: be a bit more clear about what you expect it to do

I did not see anything in the math class here, but you may want to double check:

But if I'm correct f(x) = y is very vague and just means x=y because you are not actually giving us a function to apply to x.

For example: We will use this set of inputs for x , x = {1,2,3,4,5} for both of the following problems.
The output(y) is the same as the input(x) because there is no defined function here.

Where as if it were something like this:

f(x+1)= y

The output(y) has +1 added to each of the input(x).

I think he's just saying he wants a method f where he passes a param x, he just doesn't specify what the function is supposed to do.

Whoops, sorry! Misunderstood the question.

Member Avatar

I think that this is a teaching moment here...

public int f (int x)
   int y;
   y = x;  // put your function here
   return y;

Change your data types to what you require.