Q:

Coding a loop of polynomial with a given X to find f(x) in Java

So I have trouble coding a loop of a polynomial with a given x to find f(x) in java.
To put it simply, for example, I have an array of f(x) = C[0]*x^n + C[1]*x^(n-1).......C[n]n, how would I code a loop to find f(x)  with the user's input of x?
Attached below is my incomplete function
static double poly(double[] C, double x){
            int n=C.length-1;
            int K;
            double sum=0.0;
            //loop is supposed to go here
            return sum;
}

A:

You need to increment the variable sum by each term in the polynomial i.e.
Sum += C[i]×(x^(n-i)).

So loop from i= 0 to n with the above increment operation.

