Question: Your completed program ( after modification ) will perform, at the minimum, each of the following tasks read the data from a comma separated values

Your completed program ( after modification ) will perform, at the minimum, each of the following tasks

read the data from a comma separated values ( CSV ) text file

use a split(",") function to separate the data into an ArrayList

include a method to locate a consultants name in the ArrayList

include a method to compare numerical data values in the ArrayList

include a method to compare string data values in the ArrayList

import java.io.File;

import java.io.FileNotFoundException;

import java.util.ArrayList;

import java.util.Scanner;

// Programmer: Sammy Student

public class DataApplication

{

public static void searchData(ArrayList vals)

{

System.out.print("enter a name: ");

Scanner sc = new Scanner(System.in);

String strName = sc.nextLine().trim();

boolean found = false;

for (int i = 0; i < vals.size(); i++)

{

if(vals.get(i).equals(strName.trim()))

{

found = true;

break;

}

}

if(found == true)

System.out.println(" data found ");

else

System.out.println(" data not found ");

sc.close();

}

public static void main(String[] args)

{

try

{

File fin = new File("data.txt");

Scanner scan = new Scanner(fin);

ArrayList theData = new ArrayList();

// read the column headings from the flat text file

String line = scan.nextLine();

while(scan.hasNextLine())

{

line = scan.nextLine();

String[] list = line.split(",");

int key = Integer.parseInt(list[0]);

String name = list[1];

int fee = Integer.parseInt(list[2]);

String specialty = list[3];

theData.add(String.valueOf(key));

theData.add(name);

theData.add(String.valueOf(fee));

theData.add(specialty);

}

int count = 1;

for (int i = 0; i < theData.size(); i++)

{

System.out.print(theData.get(i) + "\t\t");

if(count % 4 == 0 )

System.out.println(" ");

count++;

}

scan.close();

System.out.println(theData);

searchData(theData);

}

catch (FileNotFoundException e)

{

e.printStackTrace();

}

}

}

Modify Your Program

Now modify your program again by including a new method that will determine if any consultant charges a fee that exceeds $ 2,000 .

Save and test your program.

Finally include another method that will allow the program user to query the flat file and show a count of the consultants that specialize in providing media services.

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!