Java Practice - Algorithms
Java Practice - Algorithms
1. Enter a array of float numbers consiting of n numbers (n<=20) and save its to
the file INPUT.TXT.
2. Read data from the INPUT.TXT file, save it to a 1-demensional array and display
it on the screen.
}
public static void InsertionSort(float a[]) {
int choice;
while (true) {
System.out.println("\n -----------Menu-------------");
choice = sc.nextInt();
if (choice == 0) {
break;
switch (choice) {
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
break;
default:
sc.close();
}
*** My code:
try {
os.close();
dos.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
int choice;
while (true) {
System.out.println("\n -----------Menu-------------");
choice = sc.nextInt();
if (choice == 0) {
break;
switch (choice) {
case 1:
int n = sc.nextInt();
if (n > 20) {
} else {
arr[i] = sc.nextFloat();
al.writeFlie(arr);
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
break;
default:
sc.close();