Re: confused
- From: "CPSCmajor" <bmerritt1987@xxxxxxxxx>
- Date: 29 Oct 2005 12:49:20 -0700
Here is my code again:
import java.util.*;
public class ScoreSet
{
private ArrayList<Integer> scores;
private int average;
private int score;
private String toString;
public ScoreSet()
{
scores = new ArrayList<Integer>();
}
public void add(int score)
{
Integer wrapper = score;
scores.add(wrapper);
}
public double averageWithoutLowest2()
{
scores.add(95);
scores.add(90);
scores.add(90);
scores.add(68);
scores.add(78);
scores.add(68);
scores.add(68);
scores.add(80);
Collections.sort(scores);
average = (scores.get(2) + scores.get(3) + scores.get(4) +
scores.get(5) + scores.get(6) + scores.get(7)) / 6 ;
return average;
}
public String toString()
{
String _scores = " ";
for (int score : scores)
{
_scores += scores + " ";
}
return _scores;
}
public static void main(String[] args)
{
ScoreSet s = new ScoreSet();
//System.out.println("The average without the two lowest scores
is " + s.averageWithoutLowest2());
System.out.println(s.toString());
}
}
I still don't understand why it's displaying nothing. I added scores to
the score array in the averageWithoutLowest2 method, so I shouldn't
have to add them again should I? I am so confused.
.
- Follow-Ups:
- Re: confused
- From: andreas kinell
- Re: confused
- References:
- Re: confused
- From: CPSCmajor
- Re: confused
- Prev by Date: Re: help please
- Next by Date: tictactoe
- Previous by thread: Re: confused
- Next by thread: Re: confused
- Index(es):
Relevant Pages
|