import java.io.*;
import java.util.*;


public class lab11_2{
Scanner in=new Scanner(System.in);
private int month=12;
private int sum;
private int value;
private int rainfall;
private double total=0;
private double average;
private double standard_deviation;
private double largest;
private double smallest;
private double months[];
public lab11_2(){
months=new double[12];
}
public void setMonths(){
for(int n=1; n<=month; n++ ){
    n=in.nextInt();
}
}
public double getTotal(){
    double total=0;
    for(int i=0; i<12;i++){
        total=total+months[i];
        System.out.println("The total rainfall for the year is"+ total);
    }
    return total;
}
public double getAverage(){
    average=total/value;
    System.out.println("The average rainfall of the year is"+ average);
    total=in.nextDouble();
    return getTotal()/12;

}

public double getLargest()
{
double largest=0;
for ( int i = 0; i < 12; i++)
{
if ( months[i] > largest) 
{
largest = months[i];
System.out.println("The largest amount of rainfall was" +largest+"inches in month 8");
}

}
return largest;
}

public double getSmallest()

{
double smallest = value;
for ( sum = 1; sum < month; sum++)
{
if (value < smallest )
{
smallest = value;
System.out.println("The smallest amount of rainfall was" +smallest+"inches in month 11");
}
}
return smallest;
}
public double getStandard_deviation(){
     double n = 0; 
    standard_deviation=Math.sqrt(n);
      n=Math.pow(((rainfall-average, 2.0)/months-1)));
}
public static void main(String[]args){
    lab11_2 r =new lab11_2();
    System.out.println("Enter the rainfall (in inches) for month #1:");
    System.out.println("Enter the rainfall (in inches) for month #2:");
    System.out.println("Enter the rainfall (in inches) for month #3:");
    System.out.println("Enter the rainfall (in inches) for month #4:");
    System.out.println("Enter the rainfall (in inches) for month #5:");
    System.out.println("Enter the rainfall (in inches) for month #6:");
    System.out.println("Enter the rainfall (in inches) for month #7:");
    System.out.println("Enter the rainfall (in inches) for month #8:");
    System.out.println("Enter the rainfall (in inches) for month #9:");
    System.out.println("Enter the rainfall (in inches) for month #10:");
    System.out.println("Enter the rainfall (in inches) for month #11:");
    System.out.println("Enter the rainfall (in inches) for month #12:");
    r.setMonths();
    System.out.println(" Total" + r.getTotal());
    System.out.println("Smallest" + r.getSmallest());
    System.out.println("Largest" + r.getLargest());
    System.out.println("Average" + r.getAverage());

}

}

Im getting errors finding the standard deviation, also the program wont let me input the rainfall for each of the months...
can you guys help me?

You don't seem to call setMonths() anywhere, so that's why it's not doing anything. Perhaps you should call it at the end of your constructor?
I don't know the math for std dev, but your method:
a) sets it to sqrt(n), when n=0. Seems pointless
b) then sets n to some formula, but does nothing with it
c) doesn't return anything

When you say i didnt call set months anywhere, are you talking when i put r.setMonths() under System.out.println("Enter the rainfall (in inches) for month #12:");?

Ooops Sorry, missed it lurking there. Mea culpa. So your prog will prompt 12 times for the 12 months, then read the input for all 12. Is that what you intend? Maybe change the prompt to "enter rainfall for months 1-12", or change setMonths to take a month number as parameter and just set that one month so you can call it after each month prompt?

yup...thats what supposed to happen, but ummm...how would i take the number as parameter and set the one month?

public void setMonth(int m){
months[m] =in.nextInt();
}
...
r.setMonth(0); // etc

okay, i did this....
now getting no output

import java.io.*;
import java.util.*;


public class lab11_2{
Scanner in=new Scanner(System.in);
private int month=12;
private int sum;
private int value;
private int rainfall;
private double total=0;
private double average;
private double standard_deviation;
private double largest;
private double smallest;
private double months[];
public lab11_2(){
months=new double[12];
}
public void setMonths(int m){
for(int n=1; n<=month; n++ ){
    months[m]=in.nextInt();
    n=in.nextInt();

}
}
public double getTotal(){
    double total=0;
    for(int i=0; i<12;i++){
        total=total+months[i];
        System.out.println("The total rainfall for the year is"+ total);
    }
    return total;
}
public double getAverage(){
    average=total/value;
    System.out.println("The average rainfall of the year is"+ average);
    total=in.nextDouble();
    return getTotal()/12;

}

public double getLargest()
{
double largest=0;
for ( int i = 0; i < 12; i++)
{
if ( months[i] > largest) 
{
largest = months[i];
System.out.println("The largest amount of rainfall was" +largest+"inches in month 8");
}

}
return largest;
}

public double getSmallest()

{
double smallest = value;
for ( sum = 1; sum < month; sum++)
{
if (value < smallest )
{
smallest = value;
System.out.println("The smallest amount of rainfall was" +smallest+"inches in month 11");
}
}
return smallest;
}

public static void main(String[]args){
    lab11_2 r =new lab11_2();
    Scanner in= new Scanner(System.in);
    r.setMonths(0);
    r.setMonths(1);
    r.setMonths(2);
    r.setMonths(3);
    r.setMonths(4);
    r.setMonths(5);
    r.setMonths(6);
    r.setMonths(7);
    r.setMonths(8);
    r.setMonths(9);
    r.setMonths(10);
    r.setMonths(11);
    r.setMonths(12);
    System.out.println(" Total" + r.getTotal());
    System.out.println("Smallest" + r.getSmallest());
    System.out.println("Largest" + r.getLargest());
    System.out.println("Average" + r.getAverage());

}

}

setMonths now contains a mixture of the old code and the new, and it's really not going to work! All you need is the code I posted before. The user interface would be clearer if you left in the original prompts before each setMonths(...) call. ie
System.out.println("Enter the rainfall (in inches) for month #1:");
setMonths(0);
System.out.println("Enter the rainfall (in inches) for month #2:");
setMonths(1);
etc

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.