Create a class that holds data about a job applicant. Include a name, a phone nu
ID: 3877278 • Letter: C
Question
Create a class that holds data about a job applicant. Include a name, a phone number, and four Boolean fields that represent whether the applicant is skilled in each of the following areas: word processing, spreadsheets, databases, and graphics: Include a constructor that accepts values for each of the fields. Also include a get method for each field. Create an application that instantiates several job applicant objects and pass each in turn to a Boolean method that determines whether each applicant is qualified for an interview. Then, in the main() method, display an appropriate method for each applicant. A qualified applicant has at least three of the four skills.
Make sure your JobApplicant.java file runs with this file TestJobApplicants:
import java.util.Scanner;
public class TestJobApplicants
{
public static void main(String[] args)
{
JobApplicant app1 = new JobApplicant("Johnson", "312-345-9875",
true, false, true, false);
JobApplicant app2 = new JobApplicant("Kermit", "312-543-1275",
true, false, false, false);
JobApplicant app3 = new JobApplicant("Lawrence", "608-288-09125",
true, false, true, true);
JobApplicant app4 = new JobApplicant("Mitchell", "815-288-3881",
true, true, true, true);
String qualifiedMsg = "is qualified for an interview ";
String notQualifiedMsg = "is not qualified for an interview at this time ";
if(isQualified(app1))
display(app1, qualifiedMsg);
else
display(app1, notQualifiedMsg);
if(isQualified(app2))
display(app2, qualifiedMsg);
else
display(app2, notQualifiedMsg);
if(isQualified(app3))
display(app3, qualifiedMsg);
else
display(app3, notQualifiedMsg);
if(isQualified(app4))
display(app4, qualifiedMsg);
else
display(app4, notQualifiedMsg);
}
public static boolean isQualified(JobApplicant app)
{
int count = 0;
boolean isQual;
final int MIN_SKILLS = 3;
if(app.getHasWordSkill())
count = count + 1;
if(app.getHasSpreadsheetSkill())
count = count + 1;
if(app.getHasDatabaseSkill())
count = count + 1;
if(app.getHasGraphicsSkill())
count = count + 1;
if(count >= MIN_SKILLS)
isQual = true;
else
isQual = false;
return isQual;
}
public static void display(JobApplicant app, String msg)
{
System.out.println(app.getName() + " " + msg +
" Phone: " + app.getPhone());
}
}
You need to create the class JobApplicant.
It needs all the properties defined.
Create the constructor and the methods needed.
public class JobApplicant
{
private String name;
//The constructor. This needs to set all the properties of this class
public JobApplicant(String name, String phone, boolean w, boolean s, boolean d, boolean g)
{
this.name = name;
}
public String getName()
{
return name;
}
public boolean getHasWordSkill()
{
return hasWordSkill;
}
}
//OUTPUT should like like this:
Johnson is not qualified for an interview at this time Phone: 312-345-9875
Kermit is not qualified for an interview at this time Phone: 312-543-1275
Lawrence is qualified for an interview Phone: 608-288-09125
Mitchell is qualified for an interview Phone: 815-288-3881
Explanation / Answer
import java.util.Scanner;
class JobApplicant
{
private String name;
private String phone;
// boolean variables for word,spreadsheet,database and graphics skills
private boolean w;
private boolean s;
private boolean d;
private boolean g;
//The constructor. This needs to set all the properties of this class
public JobApplicant(String name, String phone, boolean w, boolean s, boolean d, boolean g)
{
this.name = name;
this.phone = phone;
this.w = w;
this.s = s;
this.d = d;
this.g = g;
}
public String getName()
{
return name;
}
public boolean getHasWordSkill()
{
return w;
}
//get methods
public boolean getHasSpreadsheetSkill()
{
return s;
}
public boolean getHasDatabaseSkill()
{
return d;
}
public boolean getHasGraphicsSkill()
{
return g;
}
public String getPhone()
{
return phone;
}
}
class TestJobApplicants
{
public static void main(String[] args)
{
JobApplicant app1 = new JobApplicant("Johnson", "312-345-9875",
true, false, true, false);
JobApplicant app2 = new JobApplicant("Kermit", "312-543-1275",
true, false, false, false);
JobApplicant app3 = new JobApplicant("Lawrence", "608-288-09125",
true, false, true, true);
JobApplicant app4 = new JobApplicant("Mitchell", "815-288-3881",
true, true, true, true);
String qualifiedMsg = "is qualified for an interview ";
String notQualifiedMsg = "is not qualified for an interview at this time ";
if(isQualified(app1))
display(app1, qualifiedMsg);
else
display(app1, notQualifiedMsg);
if(isQualified(app2))
display(app2, qualifiedMsg);
else
display(app2, notQualifiedMsg);
if(isQualified(app3))
display(app3, qualifiedMsg);
else
display(app3, notQualifiedMsg);
if(isQualified(app4))
display(app4, qualifiedMsg);
else
display(app4, notQualifiedMsg);
}
public static boolean isQualified(JobApplicant app)
{
int count = 0;
boolean isQual;
final int MIN_SKILLS = 3;
if(app.getHasWordSkill())
count = count + 1;
if(app.getHasSpreadsheetSkill())
count = count + 1;
if(app.getHasDatabaseSkill())
count = count + 1;
if(app.getHasGraphicsSkill())
count = count + 1;
if(count >= MIN_SKILLS)
isQual = true;
else
isQual = false;
return isQual;
}
public static void display(JobApplicant app, String msg)
{
System.out.println(app.getName() + " " + msg +
" Phone: " + app.getPhone());
}
}
Output:
Johnson is not qualified for an interview at this time Phone: 312-345-9875
Kermit is not qualified for an interview at this time Phone: 312-543-1275
Lawrence is qualified for an interview Phone: 608-288-09125
Mitchell is qualified for an interview Phone: 815-288-3881
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.