Hi i am having an issue using Math.pow its telling me that math.pow wants (double,double) and im giving it (double[] , double) is there away to use an exponent on an array

package project2;
 public class project2 {
   public static void main(String[]args){
       double x [] = { -2.0,-1.0,0,1.0,1.5,2.5,3.0,4.0,8.0,12.0,16.0,20.0,24.0};
         double f=0 , g=0 ,w=0 ;
         for (int i=0; i<x.length; i++){
          f(x)=Math.pow(x,3.0); 

Edited 3 Years Ago by mike_2000_17: Fixed formatting

Yes, loop the array and call the Math.pow for each of the elements of the array.
From what I see in your code, it is best to create a second array:

double fx [] = new double[x.length];

While you loop store each result to the new array

im sorry im new to coding could you show me what you would do

im sorry im new to coding could you show me what you would do

Sure. I would read resources and examples on Java programming, especially on the topics that my assignment covered. Then I would think about how what I had learned applies to my current assignment. Then, if I was still having trouble, I would ask specific questions that demonstrated that I had made some effort.

Since you are using loops with arrays, read how to get and set the values to each element of the array. Look at your notes or search a tutorial and you will find that what I wrote is one way to declare an array.

The loop the original array calculate the result for each of its elements and put it in the new array.

This article has been dead for over six months. Start a new discussion instead.