title: Help with java coding?
body: <p>ive been set an assignment for my java programming course and ive reached a point where i really cant work out the next step. Im wondering if anyone can help me with this code please. The assignment is as follows:</p>
  
  <p>A file exists which contains the total rainfall for each month in a year, one double value on each line. Write a program which:</p>
  
  <ul>
  <li>Asks the user to type in the name of the file.</li>
  <li>Reads the data from that file storing each value in an Array.</li>
  <li>Iterates through the Array and prints out the total rainfall for the year.</li>
  <li>Iterates through the Array and prints out the average monthly rainfall.</li>
  <li>Iterates through the Array and prints out the month with the minimum rainfall and how much that was. (Printing the name of the month will earn extra marks).</li>
  <li>Iterates through the Array and prints out the month with the most rainfall and how much that was. (Again converting the month number to a String will earn extra marks).</li>
  </ul>
  
  <p>So far i have done the first two steps and i almost have the code for the third step. </p>
  
  <p>The data file im using looks something like this:</p>
  
  <pre>
    1.80
  
    2.70
  
    3.75
  
    4.40
  
    5.20
  
    6.15
  
    7.30
  
    8.45
  
    9.60
  
    10.90
  
    11.85
  
    12.100
  </pre>
  
  <p>What i have done here is written:</p>
  
  <p>1.80</p>
  
  <p>2.70 etc meaning that the '1' will be January, the '2' will be February etc</p>
  
  <p>So the number after the full stop is the rainfall. So i need to calculate the total of all the numbers on the right hand side of each full stop.</p>
  
  <p>Then my code so far is this:</p>
  
  <pre><code>import java.util.*;
  import java.io.*;
  
  class Assignment5{
  public static void main(String[] args)throws Exception{
    String data;
  
    ArrayList&lt;Double&gt; store = new ArrayList&lt;Double&gt;();
    Scanner scanner = new Scanner(System.in);
  
    System.out.println(" "); 
    System.out.println("Please enter the name of a file with .txt at the end.");
    System.out.println(" ");
    data = scanner.nextLine();
  
    File inputFile = new File(data);
    Scanner reader = new Scanner(inputFile); 
  
    while(reader.hasNext()){
      store.add(reader.nextDouble());
    }
  
    calculateSum(store);
    store.clear();
  
  }
  
  private static void calculateSum(ArrayList&lt;Double&gt; ArrayList){
    double sum = 0;
    double avg = 0;
    double total = 0;
    double totalrainfall = 0;
  
    Iterator&lt;Double&gt; iterator = ArrayList.iterator();
  
    while(iterator.hasNext()){
      sum += iterator.next(); 
    }
  
    total = ArrayList.size();
    avg = (sum / total);
  
    System.out.println(" ");
    System.out.println("The total rainfall is " + totalrainfall);
  
  }   
  </code></pre>
  
  <p>The part im stuck on is calculating the total rainfall. The data is a double value so i need to calculate all the integers after the full stop in the data file. I cant work out how to put this into my code. Thanks for helping in advance!</p>