//Add you starting comment block public class BubbleBubbleStarter //Replace the word Starter with your initials { public static void main (String[] args) { //Task 1: create an input double array list named mylist with some values pSystem.out.println("My list before sorting is: "); //Task 2: print the original list //Use println() to start and then replace with your printList() method after Task 4a is completed. p//Task 3: call the bubblesort method for mylist p//Task 4b: print the sorted list p} //Task 4a: create a method header named printlist to accept a formal parameter of a double array //create a method body to step through each array element println each element p//printList method header p//for loop p//println statement static void bubbleSort(double[] list) { boolean changed = true; do { changed = false; for (int j = 0; j < list.length - 1; j++) if (list[j] > list[j+1]) { //swap list[j] with list[j+1] double temp = list[j]; list[j] = list[j + 1]; list[j + 1] = temp; changed = true; } } while (changed); } }
Answer:
See explaination
Explanation:
import java.util.Scanner;
public class BubbleBubbleStarter {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double arr[] = new double[10];
System.out.println("Enter 10 GPA values: ");
for (int i = 0; i < 10; i++)
arr[i] = sc.nextDouble();
sc.close();
System.out.println("My list before sorting is: ");
printlist(arr);
bubbleSort(arr);
System.out.println("My list after sorting is: ");
printlist(arr);
}
static void bubbleSort(double[] list) {
boolean changed = true;
do {
changed = false;
for (int j = 0; j < list.length - 1; j++) {
if (list[j] > list[j + 1]) {
double temp = list[j];
list[j] = list[j + 1];
list[j + 1] = temp;
changed = true;
}
}
} while (changed);
}
static void printlist(double list[]) {
for (int j = 0; j < list.length; j++) {
System.out.println(list[j]);
}
}
}
If your question is not fully disclosed, then try using the search on the site and find other answers on the subject Computers and Technology.
Find another answersComputers and Technology, published 10.03.2023
Computers and Technology, published 23.04.2023
Computers and Technology, published 17.03.2023
Which ipconfig parameter allows to view the physical address of a network interface card (nic)?