i was watching a tutorial about bubblesort, and i followed all the instructions the difference is that the tutor is using System.out while im using JOPtionPane,
please help me thank you help me find my error and help me run it correctly!
public static void main(String[] args) {
// TODO Auto-generated method stub
String ctr="";
JOptionPane.showMessageDialog(null,"Enter any 10 numbers:");
int[] points = new int[10];
for (int i=1; i<=10+1;i++){
points[i]=Integer.parseInt(JOptionPane.showInputDialog(null,"num["+i+"];"));
ctr = ctr+points[i]+ " ";
int[] sortedArray = bubbleSort(points);
}
int sortedArray = 0;
JOptionPane.showMessageDialog(null, "Numbers Entered: "+ctr+"Ascending:"+ sortedArray);
}
private static int[] bubbleSort(int[] points) {
int n=points.length;
for(int pass=1; pass<=n;pass++){
for(int current=0;current<n-pass;current++){
if(points[current]>points[current+1]){
int temp = points[current];
points[current]=points[current+1];
points[current+1]=temp;
}
}
}
return points;
}
}
thanks so much!
i hope i can get my errors ryt away coz i have to pass it today! thank you!