Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Help with ArrayList

807600Nov 7 2007 — edited Nov 7 2007
I'm very bad at java...... so I was wondering if someone could get me started on this program
public class Statistics {
private int n;
private double mean, median, standardDeviation, correlation;
private String name;

/** Creates a new instance of Statistics */
public Statistics(java.lang.String name, java.util.ArrayList<java.lang.Double> data) {
name = new String();
}

public Statistics(java.lang.String name) {
name = new String();

}




public java.lang.String name() {
return name;
}

public int n(){
return n;
}

public void add(double datum){

}

public double mean(){
return mean;
}

public double median(){
return median;
}

public double standardDeviation(){
return standardDeviation;
}

public java.util.ArrayList<java.lang.Double> zScores(){
return zScores;
}

public double correlation(Statistics other){
throw new IllegalArgumentException("mismatched n sizes");
}
}

I know this is just a skeleton of the program I am going to write. I was wondering what is wrong with my code so far.

One constructor assigns the name of the variable this Statistics object represents, and an ArrayList of Double values (the initial data). The other constructor creates an empty ArrayList of Double values.

one of the parameters of the project. I was wondering if data is the variable from the ArrayList<Double> so I would do something like for public double mean()

int sum = 0;
for (Double a: data)
sum += a;
mean = sum/data.length()

something like that. I'm pretty sure that bottom part for the mean is wrong also.

sorry about the formatting.. if someone could tell me how to put in the tabs to make the code look better i will redo it.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 5 2007
Added on Nov 7 2007
3 comments
165 views