Java coding bubbleAlgorithm, And calculate the average value of the array, and then output it as a string.
Public class variable {/*** @ Param ARGs */public static void main (string [] ARGs) {int A [] = {, 3 }; int COUNT =. length; string B = new string (); fun Ling = new fun (); B = Ling. AVG (a); // system. out. println ("B =" + B + "\ n"); // system. out. printf ("avg1 = % 5s \ n", B); system. out. println (B); Ling. bubble (a); system. out. println ("Bubble Sorting after calling:"); system. out. printf ("["); For (int K = 0; k <count; k ++) {system. out. printf (A [k] + "");} system. out. printf ("]") ;}} class Fun {Public String AVG (int A []) {int sum = 0; double avge = 0.0; int I = 0; int COUNT =. length; string avge1 = new string (); // system. out. printf ("Count = % d \ n", count); for (I = 0; I <count; ++ I) {sum + = A [I];} avge = sum/(count * 1.0); // system. out. printf ("sum =" + sum + "\ n"); system. out. printf ("AVG = %. 3f \ n ", avge); // avge1 = avge. tostring (); avge1 = string. format ("%. 3f ", avge); // string output format, three decimal places // avge1 = avge +" "; return avge1;} public void bubble (int A []) {int COUNT =. length; int temp = 0; system. out. println ("before Bubble Sorting:"); system. out. printf ("["); For (int K = 0; k <count; k ++) {system. out. printf (A [k] + "");} system. out. printf ("]"); system. out. printf ("\ n"); For (INT I = 0; I <count; I ++) for (Int J = I + 1; j <count; j ++) {if (a [I]> A [J]) {temp = A [I]; A [I] = A [J]; A [J] = temp ;}} system. out. println ("after Bubble Sorting:"); system. out. printf ("["); For (int K = 0; k <count; k ++) {system. out. printf (A [k] + "");} system. out. printf ("]"); system. out. printf ("\ n ");}}