****Build program about array of float number.
The program incluedes 6 functions:
1. Enter a array of float numbers consiting of n numbers (n<=20) and save its to
the file [Link].
2. Read data from the [Link] file, save it to a 1-demensional array and display
it on the screen.
3. Display the results of sorting the elements in the array a in item 2 in
ascending order, according to each step of the Bubble Sort algorithm (each step
displays up to 1 line) and save it to the file [Link]
4. Display the results of sorting the elements in the array a in item 2 in
ascending order, according to each step of the Selection Sort algorithm (each step
displays up to 1 line) and save it to the file [Link]
5. Display the results of sorting the elements in the array a in item 2 in
ascending order, according to each step of the Insert Sort algorithm (each step
displays up to 1 line) and save it to the file [Link].
6. Calculate the running time of the 3 algorithms: BubbleSort, SelectionSort and
InsertionSort.
***You must use this template:
public class algorithm {
public static void writeFlie(float a[]) {
public static int[] readFile(float a[], int size) {
public static void bubbleSort(float a[]) {
public static void selectionSort(float a[]) {
}
public static void InsertionSort(float a[]) {
public static void timeToRun(float a[]) {
public class main_sort {
public static void main(String[] args) throws IOException {
algorithm al = new algorithm();
Scanner sc = new Scanner([Link]);
int choice;
while (true) {
[Link]("\n -----------Menu-------------");
[Link]("| 1. Input |");
[Link]("| 2. Output |");
[Link]("| 3. Bublle Sort |");
[Link]("| 4. Selection Sort |");
[Link]("| 5. Insertion Sort |");
[Link]("| 6. Time run three sort algorihtm |");
[Link]("| 0. Exit |");
[Link](" ----------------------------- \n");
[Link](" Your selection (0 -> 6): ");
choice = [Link]();
if (choice == 0) {
[Link](" Good bye, have a nice day!");
break;
switch (choice) {
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
break;
default:
[Link]("**Invalid choice. Try again.**");
[Link]();
}
*** My code:
public class algorithm {
public static void writeFlie(float a[]) throws IOException {
try {
OutputStream os = new FileOutputStream("D:\\Study\\FUNiX\\CC3\\[Link]");
DataOutputStream dos = new DataOutputStream(os);
for (int x = 0; x < [Link]; x++) {
[Link](a[x]); // writes the bytes
[Link]();
[Link]();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
[Link]();
public static int[] readFile(float a[], int size) {
public static void bubbleSort(float a[]) {
public static void selectionSort(float a[]) {
}
public static void InsertionSort(float a[]) {
public static void timeToRun(float a[]) {
public class main_sort {
public static void main(String[] args) throws IOException {
algorithm al = new algorithm();
Scanner sc = new Scanner([Link]);
int choice;
while (true) {
[Link]("\n -----------Menu-------------");
[Link]("| 1. Input |");
[Link]("| 2. Output |");
[Link]("| 3. Bublle Sort |");
[Link]("| 4. Selection Sort |");
[Link]("| 5. Insertion Sort |");
[Link]("| 6. Time run three sort algorihtm |");
[Link]("| 0. Exit |");
[Link](" ----------------------------- \n");
[Link](" Your selection (0 -> 6): ");
choice = [Link]();
if (choice == 0) {
[Link](" Good bye, have a nice day!");
break;
switch (choice) {
case 1:
[Link](" Enter number of elements:");
int n = [Link]();
float arr[] = new float[n];
if (n > 20) {
[Link](" Number of elements is less than or equal to 20. Please try
again.");
} else {
[Link](" Enter elements: ");
for(int i = 0; i < n; i++) {
arr[i] = [Link]();
[Link](arr);
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
break;
default:
[Link]("**Invalid choice. Try again.**");
[Link]();
***Please help me complete this. Thank u!!!!