I am trying to write a simple bubble sort program but am getting an error that I can't figure out or fix. I am using textpad and get this error:
"bubbleSort.java:56: error: while expected }"
I am sure I am just making a dumb mistake. I am new to prgraming.
Here is the code:
import java.util.Scanner;
public class bubbleSort {
public static void main (String [] args) {
double [] bubbleArray = new double [10];
System.out.print ("Enter 10 numbers ");
for (int i = 0; i < bubbleArray.length; i++) {
Scanner input = new Scanner(System.in);
System.out.println(" ");
bubbleArray[i] = input.nextDouble();
}
double [] newArray = new double [10];
newArray = m(bubbleArray);
for (int i= 0; i < newArray.length - 1; i++){
System.out.println(bubbleArray[i] + " ");
}
}
public static double [] m(double [] sortedArray) {
do {
boolean changed = false;
for (int i = 0; i < sortedArray.length - 1; i++) {
if (sortedArray[i] > sortedArray[i+1]) {
double temp;
temp = sortedArray[i];
sortedArray[i] = sortedArray[i+1];
sortedArray[i+1] = temp;
changed = true;
}
else {
changed = true;
}
}while (changed);
return sortedArray;
}
}