.....already have the Person, Customer, preferredCustomer class... Finally, writ
ID: 3881262 • Letter: #
Question
.....already have the Person, Customer, preferredCustomer class...
Finally, write a test - driver program, PreferredCustomer Driver.java, to demonstrate the class. The test - driver program obtains its input from a data file ( customers.txt ).Your program should use this file name and should not ask for the name of an input file.
Program Input
The test - driver program obtains its data from a data file ( customers.ttxt ) with data organized as follows.. Each line in the input file represents a preferred customer. Therefore, each line consists of the following data values separated by a semicolon, customer name, customer address, customer phone number, customer id, a Boolean value (true/false), and a customer’s purchases amount. Here are the first few lines in a sample input file:
Julie James; 123 Main Street, Allentown, NY 11242; 567 - 555 - 1212; 147 - A049; true ; 1750.00
Bryan Thomas; 292 Main Street, Springfield, NJ 11242; 326 - 555 - 6579; 147 - A768; false ; 2750.00
Explanation / Answer
package arrays;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedList;
public class PreferredCustomerDriver {
public static void main(String[] args) {
BufferedReader reader;
try {
reader = new BufferedReader(new FileReader(
"C:\Users\user\Desktop\customers.txt"));
String line = reader.readLine();
while (line != null) {
System.out.println(line);
// read next line
line = reader.readLine();
}
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.