title: File I/O with methods
body: <p>In my program, take the user input file name with the scanner. user enter .txt file name in console and I got output in console as well but now if i want to do this program with this method :</p>
  
  <pre><code> public static double deviation(File inputFile)
  </code></pre>
  
  <p>How can I implement my program?</p>
  
  <pre><code>public static void main(String[] args) throws FileNotFoundException {
          // TODO Auto-generated method stub
          double number = 0;
          double n = 0;
  
          double sum = 0;
          double sum1 = 0;
          int count = 0;
          double mean = 0;
  
  
              Scanner Scanscan = new Scanner(System.in);
              System.out.print("Enter the name of the file: ");
              String filename = Scanscan.nextLine();
  
              File inputFile = new File(filename);
              Scanner reader = new Scanner(inputFile);
  
  
              while(reader.hasNext()){
                  number = reader.nextDouble();
                  sum = sum + number;
                  sum1 = sum1 + Math.pow(number,2);
                  n++;
              }
  
              double n1 = Math.sqrt(n);
              double sum11 = Math.sqrt(sum1);
              mean = sum / n;
  
              double n12 = Math.pow(n,2) - n;
              double n22 = Math.pow(sum, 2);
              double x = ( n * sum1 - n22) / (n12);
              double deviation = (Math.sqrt(x));
  
              System.out.println( "The standard deviation of the values in this file is: " + deviation);
  
          }
  </code></pre>