Question: Question 1: [30] Write a Java class called CleaningUp with methods that will take an existing file (the dirtycv.txt that has been given to you)

Question 1: [30]

Write a Java class called CleaningUp with methods that will take an existing file (the dirtycv.txt that has been given to you) and clean the file up. The cleaned-up version must be written to a new file called cleancv.txt file.

For question 1 create a method public void cleanUpFile(). You have been given the dirtycv.txt file (to be used as input / read). The method must re-structure the dirtycv.txt file so that each candidate can be viewed as a record, taking up exactly 1 line in the new file (the cleancv.txt). For example, CV 1 is John Smith in the dirtycv.txt file and appears as follows:

CV 1 Surname:Smith First Name:John Address:1 Whatever Street Qualification:Degree in Computer Science Position:Data Analyst Experience:5 Position:Computer programmer Experience:2 eMail:smithj@lol.com End

Once this CV is cleaned up it should appear as follows in the cleancv.txt file:

Smith0001,Degree in Computer Science,Data Analyst,5,Computer programmer,2,smithj@lol.com,

Take note that there are 5 CVs in the dirtycv.txt file and that means there needs to be 5 lines (records) in the cleancv.txt file (see above for the complete example).

The dirtycv.txt file needs to be cleaned up so that each line is formatted accordingly:

Identifier,qualification,position,experience,position,experience,eMail,

Identifier Smith0001

Qualification Degree in Computer Science

Position Data Analyst

Experience 5 (this would be 5 years)

Position Computer programmer

Experience 2

eMail smithj@lol.com

Remember that this is an example illustrating what the output could look like. This is not to say that it will always be John Smith.

Take note of the following:

  • The identifier needs to be generated, i.e. Smith0001 (it is mandatory that there is a 000 placed in front of the 1. So, CV 1 correlates to Smith0001;
  • This is a comma separated file;
  • There are no spaces between commas;
  • The last character in the line is a comma;
  • There are variations between CVs in the dirtycv.txt file, for example CV 2 has no address. Create a main() method in its own class (JobCandidatesMain) and test the program before continuing. To summarise, at the end of this question you should produce a file called the cleancv.txt file. The contents of the file should appear as follows:

Smith0001,Degree in Computer Science,Data Analyst,5,Computer programmer,2,smithj@lol.com, Harrison0002,None,harrisonj@lol.com, Jones0003,Masters in Computer Science,Operator,10,Computer programmer,2,jonesr@lol.com, Ngomi0004,Degree in Computer Science,Programmer,10,ngomim@lol.com,

Chen0005,Masters in Computer Science,Programmer,7,chenc@lol.com,

Question 2: [40] You will need to make use of the cleancv.txt file that you created in Question 1, to

complete Question 2.

Now that you have a clean file; the next step is to extract only those candidates that the agency would like to interview. In other words, the output of this question should produce a new file that only holds the candidates to be interviewed. This file should be called to-interview.txt

Create a class called CandidatesToInterview and ensure that you have relative path names for the files:

The criteria for the candidates to become potential interviewees are as follows:

The potential candidates are going to be candidates that have suitable qualifications

experience Create a method called public void findCandidates() and make use of the following

arrays as keywords to determine which candidates get chosen for interviews.

String [] keywordsDegree = {"Degree in Computer Science", "Masters in Computer Science"};

String [] keywordsExperience = {"Data Analyst", "Programmer", "Computer programmer", "Operator"};

For this assignment, these are the keywords used for the degrees as well as the years of experience. In the real world this would not be so. To clarify, the keywords array keywordsDegree means that the candidates must either have a Degree in Computer Science or a Masters in Computer Science. Similarly, the keywords array keywordsExperience are candidates that must have experience as either data analysts or Programmer or Computer programmer or Operator.

For this class, the program must determine whether a candidate in the cleancv.txt file should be chosen to be interviewed. If so, the candidate details are to be written to the to-interview.txt file based on the keywords as described above. The end result for this example is as follows:

to-interview.txt

Smith0001 Degree in Computer Science Data Analyst 5 Computer programmer 2 smithj@lol.com Jones0003 Masters in Computer Science Operator 10 Computer programmer 2 jonesr@lol.com Ngomi0004 Degree in Computer Science Programmer 10 ngomim@lol.com Chen0005 Masters in Computer Science Programmer 7 chenc@lol.com

The following form part of each line in the to-interview.txt file:

There is a space between each field (a field being Smith0001 or Degree in Computer Science, etc)

The following data is captured as part of the record o Identifier

o Qualification o Position (most current) o Years of experience (most current) o Position o Years of experience

Take note that Harrison did not make the list as they do not have a qualification. Although Ngomi0004 and Chen0005 have the experience related to being a programmer only, they still qualify. Smith0001 and Jones0003 qualify as they have experience related to 2 roles. All the qualifiers have either a Degree in Computer Science or a Masters in Computer Science.

To summarise, at the end of this question you should produce a file called the to-interview.txt file.

Go to class JobCandidatesMain and test the program before continuing.

Question 3: [10]

Following on from question 2 and staying within the class CandidatesToInterview, create another method public void candidatesWithExperience() that will produce a file only showing candidates that have more than 5 years of experience in their

current role. The current role is the first role listed, such as data analyst for Smith0001, operator for Jones0002, programmer for Ngomi0004 and programmer for Chen0005.

You will make use of the to-interview.txt file that you created in question 2, to read in the candidates. Extract only those candidates that qualify, placing them in a new file, the to-interview-experience.txt file.

to-interview-experience.txt

Jones0003 10

Ngomi0004 10

Hint: The use of a multi-dimensional array (or any other data structure) to store potential candidates (in question 2) may make it easier to extract the data from the to-interview.txt file so that you get the to-interview-experience.txt file (only those with more than 5 years experience).

To summarise, at the end of this question you should produce a file called the to-interview-experience.txt file.

Go to class JobCandidatesMain and test the program before continuing. At the end of question 3 you should have the following files as output: From Question 1

cleancv.txt -> all CVs arranged in a particular format read from dirtycv.txt From Question 2

to-interview.txt -> only the candidates that have qualified From Question 3

to-interview-experience.txt -> only the candidates that have more than 5 years; experience

Question 4: [2 x 10, write to .csv file and read from .csv file]

The last step is to place all the candidates to be interviewed (use the to-interview.txt file) into a .csv file so that the employment agency within the organisation can make use of the file in a spreadsheet. Make another method in the CandidatesToInterview class called public void createCSVFile() and read from

the to-interview.txt file to ensure that the candidates to be interviewed are placed into a to-interview-table-format.csv file. You will need to do some research around how to create a .csv file.

Hint: You can make use of the multi-dimensional array created earlier. An example of what your .csv file should look like is shown here. Take note of the

following:

the table has a heading in the first row of the spreadsheet; the eMail address is positioned correctly when there a candidate has only one

current position and experience.

to-interview-table-format.csv

Make another method (just for fun and for marks of course) called public void createReport() that reads the records from the to-interview-table- format.csv file and prints the contents to the console in the following format:

Take note that for this report only the current role is outputted. This is just a report that is sent to the console and is not related to a file. This means that you need to take a screenshot of the output and place it into a text editor file such as Word or TextEdit. The file is to be called screenshot-candidates

Go to class JobCandidatesMain and test the program before submitting. The following files are to be handed in as part of your submission:

.java source file(s) cleancv.txt to-interview.txt to-interview-experience.txt to-interview-table-format.csv screenshot-candidates (a text doc)

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!