mport java.util.Random; public class TestLength { public static void main(String[] args) { Random rand = new Random(10); Length length[] = new Length[10]; // fill length array and print for (int i = 0; i < length.length; i++) { length[i] = new Length(rand.nextInt(11) + 10, rand.nextInt(12)); System.out.print(length[i].toString() + " "); } System.out.println(); System.out.println(); // Print sum of the Length objects Length sum = sum(length); System.out.println("Sum is: "+sum); System.out.println(); // use sort method and print System.out.println("Sorted List"); selectionSort(length); for (int i = 0; i < length.length; i++) { System.out.print(length[i].toString() + " "); } System.out.println(); } public static void selectionSort(Length[] arr){ // Your code goes here } public static Length sum(Length[] list) { // Your code goes here } } _____________________________________________________ public class Length { private int feet; private int inches; // Your code goes here }
import java.util.Random;
public class TestLength {
public static void main(String[] args) {
Random rand = new Random(10);
Length length[] = new Length[10];
// fill length array and print
for (int i = 0; i < length.length; i++) {
length[i] = new Length(rand.nextInt(11) + 10, rand.nextInt(12));
System.out.print(length[i].toString() + " ");
}
System.out.println();
System.out.println();
// Print sum of the Length objects
Length sum = sum(length);
System.out.println("Sum is: "+sum);
System.out.println();
// use sort method and print
System.out.println("Sorted List");
selectionSort(length);
for (int i = 0; i < length.length; i++) {
System.out.print(length[i].toString() + " ");
}
System.out.println();
}
public static void selectionSort(Length[] arr){
// Your code goes here
}
public static Length sum(Length[] list) {
// Your code goes here
}
}
_____________________________________________________
public class Length
{
private int feet;
private int inches;
// Your code goes here
}
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 1 images