title: Need help on Java Rainfall program
body: <p>So I have to make the Java rainfall program. The thing is my professor wants me to submit it using myprogramminglab which is extremely sensitive if you don't get exactly the same output of mpl it gets marked wrong all the down to the spacing.   I've got most of the program done only thing really i'm having trouble with is outputting the largest month and smallest month as a String and the input validation.</p>
  
  <p>Here's the assignment:</p>
  
  <blockquote>
    <p>Write a RainFall class  that has the following field:</p>
    
    <p>• an array  of doubles  that stores  the rainfall for each of the 12
    months of the year (where the first index corresponds with January,
    the second with February, etc.)</p>
    
    <p>The class  should also have the following methods :</p>
    
    <p>• a method  that returns the total rainfall for the entire year<br>
    • a method  that returns the average monthly rainfall for the year<br>
    • a method  that returns the month with the most rain as a string<br>
    • a method  that returns the month with the least rain as a string   </p>
    
    <p>Demonstrate the class  in a program  that takes 12 doubles  from the
    user (take the  doubles  in the order of the months of the year, the
    first corresponding to the  rainfall in January, etc.). Do input
    validation: if the user inputs a negative number, ignore it and
    continue asking them for input until  you have 12 nonnegative doubles
    . </p>
    
    <p>Once the user has given  you all 12 doubles , create an instance of
    the RainFall class  and call its methods , printing out the total
    rainfall, the average monthly rainfall, the month with the most rain,
    and the month with the least rain, each on a separate line.</p>
  </blockquote>
  
  <p>Here's the output mpl wants the floating periods represent spaces and the arrows </p>
  
  <pre><code>newlines:
  Enter·rainfall·for·month·1:1.12↵
  Enter·rainfall·for·month·2:2.24↵
  Enter·rainfall·for·month·3:3.36↵
  Enter·rainfall·for·month·4:0.48↵
  Enter·rainfall·for·month·5:2.00↵
  Enter·rainfall·for·month·6:5.00↵
  Enter·rainfall·for·month·7:12.12↵
  Enter·rainfall·for·month·8:1.48↵
  Enter·rainfall·for·month·9:3.12↵
  Enter·rainfall·for·month·10:3.24↵
  Enter·rainfall·for·month·11:6.6↵
  Enter·rainfall·for·month·12:1.12↵
  41.88↵
  3.49↵
  July↵
  April↵
  </code></pre>
  
  <p>And here's my code</p>
  
  <pre><code>public class rainFall 
  {
  Scanner input = new Scanner(System.in);
  
  String rain[] = {"January", "Febuary", "March", "April", "May", "June", "July", "August", "September", "November", "December"};
  
          static double sum = 0;
          static double avg = 0;
          int m = 1;
          double numbers = 0;
  
          public void setSum()
          {
             while(m &lt; 13)
              {
                  System.out.print("Enter rainfall for month " + m + ":");
                  numbers = input.nextDouble();
                  sum+= numbers;
                  m++;
              } 
          }
  
          public double getSum()
          {
              return sum;
          }
  
          public void setAverage()
          {
              avg = sum / 12;
          }
  
          public double getAverage()
          {
              return avg;
          }
  
          public String getLargest()
          {
              String largest = rain[0];
              int r = 0;
  
              for(int i = 0; i &lt; numbers; i++)
              {
                  if(rain[i] &gt; numbers)
                  {
                      r = i;
                  }
              }
  
              return r;
          }
  
  
      public static void main(String[] args) {
  
          rainFall rf = new rainFall();
          rf.setSum();
          rf.setAverage();
  
          System.out.println(rf.getSum());
          System.out.println(rf.getAverage());
      }
  }
  </code></pre>
  
  <p>My only errors are  bad operands types at the if statement and the return statement in getLargest()</p>