//sortbyweight. use bucket sort to sort the letters into four
//sortByWeight. Use bucket sort to sort the letters into four categories.
public static LinkedList[] sortByWeight(Letter[] letters) {
//code
}
public class Tester
{
public static void main(String[] args)
{
Letter[] letters = new Letter[10];
letters[0] = new Letter(“Abby”, “55555”, 0.2);
letters[1] = new Letter(“Joaquin”, “24689”, 0.25);
letters[2] = new Letter(“Frank”, “34567”, 0.3);
letters[3] = new Letter(“Ben”, “76543”, 3.2);
letters[4] = new Letter(“Evgeni”, “15212”, 0.2);
letters[5] = new Letter(“John”, “11111”, 5.2);
letters[6] = new Letter(“Evan”, “55555”, 10.4);
letters[7] = new Letter(“Will”, “86793”, 0.1);
letters[8] = new Letter(“Thong”, “90515”, 1.4);
letters[9] = new Letter(“Jan”, “90120”, 20.2);
LinkedList[] sortedByWeight = LetterSorter.sortByWeight(letters);
System.out.println(“Actual: ” + sortedByWeight[0].contains(letters[0]));
System.out.println(“Expected: true”);
System.out.println(“Actual: ” + sortedByWeight[1].contains(letters[8]));
System.out.println(“Expected: true”);
public class Letter
{
public String to;
public String zipcode;
public double weight;
public Letter(String to, String zipcode, double weight)
{
this.to = to;
this.zipcode = zipcode;
this.weight = weight;
}
}