JAVA...
QUESTION 3 IS A CONTINOUS TO Q2 CAN YOU SEND THE CODE SEPARATELY FOR EACH Q , I BE SO THANKFUL
Q2.
Implement a program to store the applicant’s information for a visa office. You need to implement the following:
A super class called Applicant, which has the following instance variables:
The class should have the following methods:
An applicant can be self employed or employed. For each type of applicants a sub class should be implemented. Self Employed that inherits from the super class and has the following instance variables:
The class should have the following methods:
A sub class Employed that inherits from the super class and has the following instance variables:
The class should have the following methods:
Implement a test function that lists the information of the applicant using toString() method.
Sample output:
Applicant 1:
Name: Mohammed Ali
Date of Birth: 01/Jan/1970
Works at: ABC Co. for 3 years
Salary: 2000KD
Average Account Balance:
1500KD
Title: Sales Manager
Applicant 2:
Name: John Smith
Date of Birth: 01/Mar/1975
Owns: XYZ Co. for 10 years
Capital: 50000KD
Average Account Balance:
2000KD
Average Co. Account Balance:
2500KD
Number of Employees: 10
Q3.
For the previous question apply some changes to add a functionality that evaluates if the applicant is Approved, Rejected or Needs Extra Review.
Change Applicant class to an abstract class and add an abstract method called evaluate().
In SelfEmployed class, evaluate() method is implemented as follows:
If capital of company is less than 5000 then the application is rejected.
If the average company account balance is less than 3000 and the capital is less than 10,000 then the application is rejected.
If the average company account balance is between 3000 and 5000, the capital is between 10,000 and 15,000 then the application needs extra review.
If the average company account balance is less than 3000, and the number of employees is less than 15 then the application needs extra review.
If the average company account balance is less than 3000, and the average personal account balance is less than 1000 then the application needs extra review.
In all other cases the application is Approved.
In Employed class, evaluate() method is implemented as follows:
If the average account balance is less than 1000 and the salary is less than 1000 then the application is rejected.
If the salary is less than 1000 and the number of years of employment is less than 3 then the application is rejected.
If the average account balance is between 1000 and 1500, and the number of years of employment is less than 3 then the application needs extra review.
In all other cases the application is Approved.
Sample output:
Applicant 1:
Name: Mohammed Ali
Date of Birth: 01/Jan/1970
Works at: ABC Co. for 3 years
Salary: 2000KD
Average Account Balance:
1500KD
Title: Sales Manager
Evaluation: Approved
Applicant 2:
Name: John Smith
Date of Birth: 01/Mar/1975
Owns: XYZ Co. for 10 years
Capital: 50000KD
Average Account Balance:
2000KD
Average Co. Account Balance:
2500KD
Number of Employees: 10
Evaluation: Rejected
Q2.
class Date
{
private String month;
private int day;
private int year;
public Date()
{
this.day = 0;
this.month= "";
this.year = 0;
}
public Date(int day, String month, int year)
{
this.day = day;
this.month= month;
this.year = year;
}
public void setMonth(String month)
{
this.month = month;
}
public String getMonth()
{
return this.month;
}
public void setDay(int day)
{
this.day = day;
}
public int getDay()
{
return this.day;
}
public void setYear(int year)
{
this.year = year;
}
public int getYear()
{
return this.year;
}
public String toString()
{
return "" + day + "/" + month + "/"
+ year;
}
}
public class Applicant
{
private String firstName;
private String lastName;
private Date dateOfBirth;
private int noYearsWorking;
private String company;
private double avgAccBalance;
public Applicant()
{
firstName="";
lastName="";
dateOfBirth=null;
noYearsWorking=0;
company="";
avgAccBalance=0.0;
}
public Applicant(String firstName, String lastName,
Date dateOfBirth, int noYearsWorking, String company, double
avgAccBalance)
{
this.firstName=firstName;
this.lastName=lastName;
this.dateOfBirth=dateOfBirth;
this.noYearsWorking=noYearsWorking;
this.company=company;
this.avgAccBalance=avgAccBalance;
}
public void setFirstName(String firstName)
{
this.firstName=firstName;
}
public String getFirstName()
{
return this.firstName;
}
public void setLastName(String lastName)
{
this.lastName=lastName;
}
public String getLastName()
{
return this.lastName;
}
public void setDateOfBirth(Date dateOfBirth)
{
this.dateOfBirth=dateOfBirth;
}
public Date getDateOfBirth()
{
return this.dateOfBirth;
}
public void setNoYearsWorking(int
noYearsWorking)
{
this.noYearsWorking=noYearsWorking;
}
public int getNoYearsWorking()
{
return this.noYearsWorking;
}
public void setCompany(String company)
{
this.company=company;
}
public String getCompany()
{
return this.company;
}
public void setAvgAccBalance(double
avgAccBalance)
{
this.avgAccBalance=avgAccBalance;
}
public double getAvgAccBalance()
{
return this.avgAccBalance;
}
public String toString()
{
return "Name: " + firstName + " " +
lastName + "\n" +
"Date of Birth:
" + dateOfBirth.toString() + "\n"+
"Number of years
working: " + noYearsWorking + "\n" +
"Company: " +
company +"\n" +
"Average
personal bank account balance: " + avgAccBalance + "KD";
}
}
class SelfEmployed extends Applicant
{
private double capital;
private double businessAvgAccBalance;
private int noEmployees;
public SelfEmployed()
{
super();
this.capital=0.0;
this.businessAvgAccBalance=0.0;
this.noEmployees=0;
}
public SelfEmployed(String firstName, String lastName,
Date dateOfBirth, int noYearsWorking, String company, double
avgAccBalance,
double capital, double
businessAvgAccBalance, int noEmployees)
{
super(firstName, lastName, dateOfBirth,
noYearsWorking, company, avgAccBalance);
this.capital=capital;
this.businessAvgAccBalance=businessAvgAccBalance;
this.noEmployees=noEmployees;
}
public void setCapital(double capital)
{
this.capital=capital;
}
public double getCapital()
{
return this.capital;
}
public void setBusinessAvgAccBalance(double
businessAvgAccBalance)
{
this.businessAvgAccBalance=businessAvgAccBalance;
}
public double getBusinessAvgAccBalance()
{
return
this.businessAvgAccBalance;
}
public void setNoEmployees(int noEmployees)
{
this.noEmployees=noEmployees;
}
public int getNoEmployees()
{
return this.noEmployees;
}
public String toString()
{
return "Name: " + getFirstName() +
" " + getLastName()+ "\n" +
"Date of Birth:
" + getDateOfBirth().toString() + "\n" +
"Owns: " +
getCompany() + " for " + getNoYearsWorking() + " years" + "\n"
+
"Capital: " +
capital + "KD" + "\n" +
"Average Account
Balance: " + getAvgAccBalance() + "KD" + "\n" +
"Average Co.
Account Balance: " + businessAvgAccBalance + "KD" + "\n" +
"Number of
Employees: " + noEmployees;
}
}
class Employed extends Applicant
{
private double salary;
private String title;
public Employed()
{
super();
this.salary=0.0;
this.title="";
}
public Employed(String firstName, String lastName,
Date dateOfBirth, int noYearsWorking, String company, double
avgAccBalance,
double salary, String title)
{
super(firstName, lastName, dateOfBirth,
noYearsWorking, company, avgAccBalance);
this.salary=salary;
this.title=title;
}
public void setSalary(double salary)
{
this.salary=salary;
}
public double getSalary()
{
return this.salary;
}
public void setTitle(String title)
{
this.title=title;
}
public String getTitle()
{
return this.title;
}
public String toString()
{
return "Name: " + getFirstName() +
" " + getLastName() + "\n" +
"Date of Birth:
" + getDateOfBirth().toString() + "\n" +
"Works at: " +
getCompany() + " for " + getNoYearsWorking() + " years" + "\n"
+
"Salary: " +
salary + "KD" + "\n" +
"Average Account
Balance: " + getAvgAccBalance() + "KD" + "\n" +
"Title: " +
title;
}
}
class DriverQ2
{
public static void main (String[] args)
{
Employed emp = new
Employed("Mohammed", "Ali", new Date(01, "Jan", 1970), 3, " ABC
Co.", 1500, 2000, "Sales Manager");
SelfEmployed semp = new
SelfEmployed("John", "Smith", new Date(01, "Mar", 1975), 10, "XYZ
Co.", 2000, 50000, 2500, 10);
System.out.println("Applicant 1:
\n" + emp);
System.out.println("Applicant 2:
\n" + semp);
}
}
Output:
Applicant 1:
Name: Mohammed Ali
Date of Birth: 1/Jan/1970
Works at: ABC Co. for 3 years
Salary: 2000.0KD
Average Account Balance: 1500.0KD
Title: Sales Manager
Applicant 2:
Name: John Smith
Date of Birth: 1/Mar/1975
Owns: XYZ Co. for 10 years
Capital: 50000.0KD
Average Account Balance: 2000.0KD
Average Co. Account Balance: 2500.0KD
Number of Employees: 10
Q3.
class Date
{
private String month;
private int day;
private int year;
public Date()
{
this.day = 0;
this.month= "";
this.year = 0;
}
public Date(int day, String month, int year)
{
this.day = day;
this.month= month;
this.year = year;
}
public void setMonth(String month)
{
this.month = month;
}
public String getMonth()
{
return this.month;
}
public void setDay(int day)
{
this.day = day;
}
public int getDay()
{
return this.day;
}
public void setYear(int year)
{
this.year = year;
}
public int getYear()
{
return this.year;
}
public String toString()
{
return "" + day + "/" + month + "/"
+ year;
}
}
abstract class Applicant
{
private String firstName;
private String lastName;
private Date dateOfBirth;
private int noYearsWorking;
private String company;
private double avgAccBalance;
public Applicant()
{
firstName="";
lastName="";
dateOfBirth=null;
noYearsWorking=0;
company="";
avgAccBalance=0.0;
}
public Applicant(String firstName, String lastName,
Date dateOfBirth, int noYearsWorking, String company, double
avgAccBalance)
{
this.firstName=firstName;
this.lastName=lastName;
this.dateOfBirth=dateOfBirth;
this.noYearsWorking=noYearsWorking;
this.company=company;
this.avgAccBalance=avgAccBalance;
}
public void setFirstName(String firstName)
{
this.firstName=firstName;
}
public String getFirstName()
{
return this.firstName;
}
public void setLastName(String lastName)
{
this.lastName=lastName;
}
public String getLastName()
{
return this.lastName;
}
public void setDateOfBirth(Date dateOfBirth)
{
this.dateOfBirth=dateOfBirth;
}
public Date getDateOfBirth()
{
return this.dateOfBirth;
}
public void setNoYearsWorking(int
noYearsWorking)
{
this.noYearsWorking=noYearsWorking;
}
public int getNoYearsWorking()
{
return this.noYearsWorking;
}
public void setCompany(String company)
{
this.company=company;
}
public String getCompany()
{
return this.company;
}
public void setAvgAccBalance(double
avgAccBalance)
{
this.avgAccBalance=avgAccBalance;
}
public double getAvgAccBalance()
{
return this.avgAccBalance;
}
public String toString()
{
return "Name: " + firstName + " " +
lastName + "\n" +
"Date of Birth:
" + dateOfBirth.toString() + "\n"+
"Number of years
working: " + noYearsWorking + "\n" +
"Company: " +
company +"\n" +
"Average
personal bank account balance: " + avgAccBalance + "KD";
}
public abstract String evaluate();
}
class SelfEmployed extends Applicant
{
private double capital;
private double businessAvgAccBalance;
private int noEmployees;
public SelfEmployed()
{
super();
this.capital=0.0;
this.businessAvgAccBalance=0.0;
this.noEmployees=0;
}
public SelfEmployed(String firstName, String lastName,
Date dateOfBirth, int noYearsWorking, String company, double
avgAccBalance,
double capital, double
businessAvgAccBalance, int noEmployees)
{
super(firstName, lastName, dateOfBirth,
noYearsWorking, company, avgAccBalance);
this.capital=capital;
this.businessAvgAccBalance=businessAvgAccBalance;
this.noEmployees=noEmployees;
}
public void setCapital(double capital)
{
this.capital=capital;
}
public double getCapital()
{
return this.capital;
}
public void setBusinessAvgAccBalance(double
businessAvgAccBalance)
{
this.businessAvgAccBalance=businessAvgAccBalance;
}
public double getBusinessAvgAccBalance()
{
return
this.businessAvgAccBalance;
}
public void setNoEmployees(int noEmployees)
{
this.noEmployees=noEmployees;
}
public int getNoEmployees()
{
return this.noEmployees;
}
public String toString()
{
return "Name: " + getFirstName() +
" " + getLastName()+ "\n" +
"Date of Birth:
" + getDateOfBirth().toString() + "\n" +
"Owns: " +
getCompany() + " for " + getNoYearsWorking() + " years" + "\n"
+
"Capital: " +
capital + "KD" + "\n" +
"Average Account
Balance: " + getAvgAccBalance() + "KD" + "\n" +
"Average Co.
Account Balance: " + businessAvgAccBalance + "KD" + "\n" +
"Number of
Employees: " + noEmployees;
}
public String evaluate()
{
if(capital<5000) return
"Rejected";
if(businessAvgAccBalance<3000
&& capital<10000) return "Rejected";
if(businessAvgAccBalance>=3000
&& businessAvgAccBalance<=5000 &&
capital>=10000 && capital<=15000 ) return
"Review";
if(businessAvgAccBalance<3000
&& noEmployees<15) return "Review";
if(businessAvgAccBalance<3000
&& getAvgAccBalance()<1000) return "Review";
return "Approved";
}
}
class Employed extends Applicant
{
private double salary;
private String title;
public Employed()
{
super();
this.salary=0.0;
this.title="";
}
public Employed(String firstName, String lastName,
Date dateOfBirth, int noYearsWorking, String company, double
avgAccBalance,
double salary, String title)
{
super(firstName, lastName, dateOfBirth,
noYearsWorking, company, avgAccBalance);
this.salary=salary;
this.title=title;
}
public void setSalary(double salary)
{
this.salary=salary;
}
public double getSalary()
{
return this.salary;
}
public void setTitle(String title)
{
this.title=title;
}
public String getTitle()
{
return this.title;
}
public String toString()
{
return "Name: " + getFirstName() +
" " + getLastName() + "\n" +
"Date of Birth:
" + getDateOfBirth().toString() + "\n" +
"Works at: " +
getCompany() + " for " + getNoYearsWorking() + " years" + "\n"
+
"Salary: " +
salary + "KD" + "\n" +
"Average Account
Balance: " + getAvgAccBalance() + "KD" + "\n" +
"Title: " +
title;
}
public String evaluate()
{
if(getAvgAccBalance()<1000
&& salary<1000) return "Rejected";
if(getAvgAccBalance()<1000
&& getNoYearsWorking()<3) return "Rejected";
if(getAvgAccBalance()>=1000
&& getAvgAccBalance()<=1500 &&
getNoYearsWorking()<3) return "Review";
return "Approved";
}
}
class DriverQ2
{
public static void main (String[] args)
{
Employed emp = new
Employed("Mohammed", "Ali", new Date(01, "Jan", 1970), 3, " ABC
Co.", 1500, 2000, "Sales Manager");
SelfEmployed semp = new
SelfEmployed("John", "Smith", new Date(01, "Mar", 1975), 10, "XYZ
Co.", 2000, 50000, 2500, 10);
System.out.println("Applicant 1:
\n" + emp);
System.out.println("Evaluation:" +
emp.evaluate());
System.out.println("Applicant 2:
\n" + semp);
System.out.println("Evaluation:" +
semp.evaluate());
}
}
Output:
Applicant 1:
Name: Mohammed Ali
Date of Birth: 1/Jan/1970
Works at: ABC Co. for 3 years
Salary: 2000.0KD
Average Account Balance: 1500.0KD
Title: Sales Manager
Evaluation:Approved
Applicant 2:
Name: John Smith
Date of Birth: 1/Mar/1975
Owns: XYZ Co. for 10 years
Capital: 50000.0KD
Average Account Balance: 2000.0KD
Average Co. Account Balance: 2500.0KD
Number of Employees: 10
Evaluation:Review
Note: There is a mistake in your code output of Q3. In the problem the following statement is given:
"If the average company account balance is less than 3000, and the number of employees is less than 15 then the application needs extra review."
Now see the data for Applicant 2, company account balance 2500 and the number of employees is 10.
In your sample output "Rejected" is given for Applicant 2, but it should be "Review" as per given instruction.
JAVA... QUESTION 3 IS A CONTINOUS TO Q2 CAN YOU SEND THE CODE SEPARATELY FOR EACH...
Java Question 3 Implement a program to store the applicant's information for a visa office. You need to implement the following: A super class called Applicant, which has the following instance variables: A variable to store first name of type String. A variable to store last name of type String. A variable to store date of birth, should be implemented as another class to store day, month and year. A variable to store number of years working of type integer...
Java Program (PLEASE PROVIDE SCREENSHOT OF THE CODE) Create a class Person which is a super class. The class includes four private String instance variables: first name, last name, social security number, and state. Write a constructor and get methods for each instance variable. Also, add a toString method to print the details of the person. After that create a class Teacher which extends the class, Person. Add a private instance variable to store number of courses. Write a constructor...
JAVA :The following are descriptions of classes that you will create. Think of these as service providers. They provide a service to who ever want to use them. You will also write a TestClass with a main() method that fully exercises the classes that you create. To exercise a class, make some instances of the class, and call the methods of the class using these objects. Paste in the output from the test program that demonstrates your classes’ functionality. Testing...
You are to write a banking application in c# that keeps track of bank accounts. It will consist of three classes, Account, Bank and BankTest. The Account class is used to represent a savings account in a bank. The class must have the following instance variables: a String called accountID a String called accountName a two-dimensional integer array called deposits (each row represents deposits made in a week). At this point it should not be given any initial value. Each...
HW question: Write an iterative method printHighEarners() to print all high earner employees. Method printHighEarners()is in the class LinkedList. LinkedList has private instance variable list of Node type. Class Node is private inner class inside of class LinkedList, and has public instance variables: data and next of Employee and Node type, respectively. In addition, class Node has constructor and toString method. See LinkedList class bellow on the right. Class Employee has getters for all data, method String toString() that returns...
Please explain each line of code, all code will be in Java. Thank you JKL Restaurant maintains a members’ club for its customers. There are three levels of membership: (1) Basic, (2) Silver, and (3) Gold. A certain member has to be exactly a Basic, Silver, or Gold member at any point in time. Whenever a member spends money at JKL, he/she gets points and as these points are accumulated, one can redeem one or more $20 dining certificates. Each Gold member can...
Code in JAVA UML //TEST HARNESS //DO NOT CHANGE CODE FOR TEST HARNESS import java.util.Scanner; // Scanner class to support user input public class TestPetHierarchy { /* * All the 'work' of the process takes place in the main method. This is actually poor design/structure, * but we will use this (very simple) form to begin the semester... */ public static void main( String[] args ) { /* * Variables required for processing */ Scanner input = new Scanner( System.in...
In Java, define classes for a LikeYelp class that manages reviews about stores. You need to fill in the LikeYelp class and outline supporting classes. For the supporting classes, you need to provide the signatures for the methods and enough instance variables to support the methods, but you do not need to write the code for the methods. You need to write the entire LikeYelp class so it supports the following Add a store, which has a name and an...
This assignment shpuld be code in java. Thanks Overview In this assignment you will write a program that will model a pet store. The program will have a Pet class to model individual pets and the Assignment5 class will contain the main and act as the pet store. Users will be able to view the pets, make them age a year at a time, add a new pet, and adopt any of the pets. Note: From this point on, your...
In Java Code Needed is Below the Question Using Program 3: Encapsulating Dogs, modify this program to create a database of dogs of your own. You will also include File I/O with this program. You will create 3 classes for this assignment. The first class: Create a Class representing the information that is associated with one item (one dog) of your database. Name this class Dog. Using Lab 3, this will include the information in regard to one dog. The...