title: Read variables from static method into main method as argument when calling the method
body: <p>I am having trouble on fixing my program, In my last two lines of code, when I call the static method for surfaceGravity, the compiler complains about the argument radius with the statement "incompatible: double cannot be converted to a double[]" and when I call the static method for display, the compiler complains about the argument g with the statement "cannot find symbol". How do I fix this? Any help will be greatly appreciated. Below is my code:</p>
  
  <pre><code>import java.util.Scanner;
  import java.io.File;
  import java.io.IOException;
  import java.io.PrintWriter;
  
  public class GravityV1{
  
  // calculate surface gravity static method
  public static double[] surfaceGravity(double G, double[] M, double[] r){
  
      // surface gravity variable
      double[] g = new double[M.length];
  
      for(int i = 0; i &lt; g.length; i++){
  
          // equation for calculating surface gravity
          g[i] = (G * M[i]) / Math.pow(r[i], 2);
      }
  
      // return statement
      return g;
  }
  
  // displaying static method
  
  // write results to text file static method
  public static String[] writeToFile() throws IOException{
  
      int index = 0;
      String[] data = new String[index];
      File filename = new File("/Users/timothylee/Gravity1.txt");
      Scanner inFile = new Scanner(filename);
      while(inFile.hasNext()){
  
          data[index] = inFile.next( );
  
          index++;
  
      }
  
      inFile.close();
      return data;
  }
  
  public static void main(String args[]) throws IOException{
  
      // declare array for months
      String[] Planets = new String[8];
  
      // initialize array
      Planets [0] = "Mercury";
      Planets [1] = "Venus";
      Planets [2] = "Earth";
      Planets [3] = "Mars";
      Planets [4] = "Jupiter";
      Planets [5] = "Saturn";
      Planets [6] = "Uranus";
      Planets [7] = "Neptune";
  
      // declare array for mass
      double[] mass = new double[8];
  
      // initialize array
      mass [0] = 3.30E23;
      mass [1] = 4.869E24;
      mass [2] = 5.97E24;
      mass [3] = 6.4219E23;
      mass [4] = 1.900E27;
      mass [5] = 5.68E26;
      mass [6] = 8.683E25;
      mass [7] = 1.0247E26;
  
      // declare array for diameter
      double[] diameter = new double[8];
  
      // initialize array
      diameter [0] = 4880;
      diameter [1] = 12103.6;
      diameter [2] = 12756;
      diameter [3] = 6794;
      diameter [4] = 142984;
      diameter [5] = 120536;
      diameter [6] = 51118;
      diameter [7] = 49532;
  
  
      double[] surfaceG = new double[8];
      // // convert to radius
  
      // declare radius variable
      double radius = 0;
  
      // for each loop for displaying
      for(double calc : diameter){
  
          // calculation for converting to radius
          radius =  calc / 2;
      }
  
      // // calculate surface gravity
  
      // declare and initialize universal gravity constant;
      double G = 6.67384 * Math.pow(10, -11);
  
      // call surface gravity method
      surfaceGravity(G, mass, radius);
  
      // display result
      display(Planets, radius, mass, g);
  }
  }
  </code></pre>