Question: import java.util. * ; import java.io . * ; public class LabProgram { public static void main ( String [ ] args ) { Scanner

import java.util.*;
import java.io.*;
public class LabProgram {
public static void main(String [] args){
Scanner scnr = new Scanner(System.in);
int size;
// Input # of customers and create parallel arrays
size = scnr.nextInt();
String [] names = new String[size];
double [] debt = new double[size];
String [] states = new String[size];
// Fill arrays with data from external file (described in another section)
readCustomerData(names, states, debt);
/* Type your code here */
}
// Read customer information from text file
// Make no changes to the following code
public static void readCustomerData(String [] names, String [] states, double [] debt){
// Read all data from file
try {
File f = new File("CustomerNames.csv");
Scanner scnr = new Scanner(f);
scnr.useDelimiter("[,\r
]+");
for (int index =0; index < names.length; ++index){
names[index]= scnr.next(); // last name
states[index]= scnr.next(); // state of residence
debt[index]= scnr.nextDouble(); // amount of debt
}
scnr.close();
}
// What if data file not found?
catch(IOException e){
System.out.println("Failed to read the data file: ");
}
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!