Thank you for visiting java Lab14Sort java import java util Scanner import java io File import java io IOException import java util ArrayList public class Lab14Sort public static void. This page is designed to guide you through key points and clear explanations related to the topic at hand. We aim to make your learning experience smooth, insightful, and informative. Dive in and discover the answers you're looking for!

```java
Lab14Sort.java

import java.util.Scanner;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;

public class Lab14Sort {
public static void main(String[] args) throws IOException {
String filename = null;
Scanner scnr = null;
Scanner tokens = null;
double value = 0.0;

// 1. Instantiate an ArrayList object named myList for type Double.
ArrayList myList = new ArrayList<>();

// This logic will use the command line argument or prompt for input:
if (args.length != 0) { // args is an array!
filename = args[0];
} else {
scnr = new Scanner(System.in);
System.out.println("Enter filename:");
filename = scnr.nextLine().strip();
}

// 2. Open the file to read using the File and Scanner classes:
File fHandle = new File(filename);
tokens = new Scanner(fHandle);

int counter = 0; // This counts the numbers as they are read.
myList.add(tokens.nextDouble()); // put first item in list.
++counter; // Count it.

while (tokens.hasNext()) {
// 3. Get the next number from the data file.
value = tokens.nextDouble();

// 4. Place the current number into your list and count it.
myList.add(value);
++counter;
} // repeat until all numbers are loaded into the ArrayList.

// 5. Confirm your ArrayList is populated with the data by printing
System.out.println("Data in ArrayList:");
for (Double num : myList) {
System.out.println(num);
}

if (scnr != null) {
scnr.close();
}
if (tokens != null) {
tokens.close();
}
}
}
```

**data14.txt**
```
29.4 7.7 19.454 23.6
3.33 2.5 47.5 55.1
6.9 11.0 97.8 4.45 12.3
3.33 5.454 62.8 1.0 99.8
```

Answer :

The modified Lab14Sort.java program that reads numbers from the data14.txt file and populates an ArrayList is below.

We have,

Here is the modified Lab14Sort.java program that reads numbers from the data14.txt file and populates an ArrayList:

import java.util.Scanner;

import java.io.File;

import java.io.IOException;

import java.util.ArrayList;

public class Lab14Sort {

public static void main(String[] args) throws IOException {

String filename = null;

Scanner scnr = null;

Scanner tokens = null;

ArrayList myList = new ArrayList<>(); // 1. Instantiate an ArrayList object named myList for type Double.

// This logic will use the command line argument or prompt for input:

if (args.length != 0)

filename = args[0];

else {

scnr = new Scanner(System.in);

System.out.print("Enter filename: ");

filename = scnr.nextLine().strip();

}

// 2. Open the file to read using the File and Scanner classes:

File fHandle = new File(filename);

tokens = new Scanner(fHandle);

int counter = 0; // This counts the numbers as they are read.

myList.add(tokens.nextDouble()); // put the first item in the list.

++counter; // Count it.

while (tokens.hasNext()) {

// 3. Get the next number from the data file.

double number = tokens.nextDouble();

// 4. Place the current number into your list and count it.

myList.add(number);

++counter; // Count it.

} // repeat until all numbers are loaded into the ArrayList.

// 5. Confirm your ArrayList is populated with the data by printing

for (double num : myList) {

System.out.print(num + " ");

}

if (scnr != null) {

scnr.close();

}

if (tokens != null) {

tokens.close();

}

}

}

Make sure to have the data14.txt file in the same directory as the Java file, and you can run this program to read the numbers from the file and populate the ArrayList.

Thus,

The modified Lab14Sort.java program that reads numbers from the data14.txt file and populates an ArrayList is above.

Learn more about Java programs here:

https://brainly.com/question/2266606

#SPJ4

Thank you for reading the article java Lab14Sort java import java util Scanner import java io File import java io IOException import java util ArrayList public class Lab14Sort public static void. We hope the information provided is useful and helps you understand this topic better. Feel free to explore more helpful content on our website!

Rewritten by : Jeany