The program is an illustration of methods
<h3>What are methods</h3>
Methods are collections of named code statements, that are executed when evoked
<h3>The actual program</h3>
The program written in Java, where comments are used to explain each line is as follows:
//This defines the print method
public static void print(ArrayList<Double> myArrayList){
//This iterates through the ArrayList
for(double num : myArrayList) {
//This prints every element in the list
System.out.print(num + " ");
}
System.out.println();
}
//This defines the condense method
public static void condense(ArrayList<Double> myArrayList){
//This defines a new ArrayList
ArrayList<Double> newList = new ArrayList<>();
//The following condenses the list
for(int i = 0; i < myArrayList.size(); i+=2){
newList.add(myArrayList.get(i) * myArrayList.get(i + 1));
}
//This prints every element in the list
for(double num : newList) {
System.out.print(num + " ");
}
System.out.println();
}
//Thid defines the duplicate method
public static void duplicate(ArrayList<Double> myArrayList){
ArrayList<Double> newList = new ArrayList<>();
//The following duplicates the list
for(int i = 0; i < myArrayList.size(); i++){
newList.add(myArrayList.get(i));
newList.add(myArrayList.get(i));
}
//This prints every element in the list
for(double num : newList) {
System.out.print(num + " ");
}
}
Read more about methods at:
brainly.com/question/15683939