Question 3 Implement a program to store the applicant\'s information for a visa
ID: 3706962 • Letter: Q
Question
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 A variable to store name of company where the applicant works. A variable to store average personal bank account balance for last six months of type double. The class should have the following methods: A constructor that sets the instance variables . A set method for each instance variable . A get method for each instance variable A toString to display class information 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: A variable to store capital of business of type double. A variable to store average Business bank account balance for the last six months. A variable to store number of employees in the business of type integer A constructor that sets the instance variables A get method for each instance variable The class should have the following methods: .A set method for each instance variable A toString to display class information A sub class Employed that inherits from the super class and has the following instance variables: A variable to store salary of type double. A variable to store title of type String. The class should have the following methods: A constructor that sets the instance variables A set method for each instance variable .A get method for each instance variable A toString to display class informationExplanation / Answer
/* below is the complete code and all the classes
*/
package learning;
public class Applicant {
String firstName;
String lastName;
int numberOfyear;
String companyName;
DateOfBirth dob;
double averageLastSixthMonBalance;
public Applicant(String firstName, String lastName, int numberOfyear,String companyName, DateOfBirth dob, double averageLastSixthMonBalance ){
this.firstName = firstName;
this.lastName = lastName;
this.numberOfyear = numberOfyear;
this.companyName = companyName;
this.dob = dob;
this.averageLastSixthMonBalance = averageLastSixthMonBalance;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public int getNumberOfyear() {
return numberOfyear;
}
public void setNumberOfyear(int numberOfyear) {
this.numberOfyear = numberOfyear;
}
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public DateOfBirth getDob() {
return dob;
}
public void setDob(DateOfBirth dob) {
this.dob = dob;
}
public double getAverageLastSixthMonBalance() {
return averageLastSixthMonBalance;
}
public void setAverageLastSixthMonBalance(double averageLastSixthMonBalance) {
this.averageLastSixthMonBalance = averageLastSixthMonBalance;
}
public String toString(){
return "Applicant:[ firstName: " + firstName + " , lastName: " + lastName + ", numberOfyear: " + numberOfyear + ", companyName: " + companyName + ", dob: " + dob + ",averageLastSixthMonBalance: " + averageLastSixthMonBalance;
}
}
class SelfEmployed extends Applicant{
double businessCapital;
double averageLastBusinessBankAccount;
int numberOfEmployee;
public double getBusinessCapital() {
return businessCapital;
}
public void setBusinessCapital(double businessCapital) {
this.businessCapital = businessCapital;
}
public double getAverageLastBusinessBankAccount() {
return averageLastBusinessBankAccount;
}
public void setAverageLastBusinessBankAccount(
double averageLastBusinessBankAccount) {
this.averageLastBusinessBankAccount = averageLastBusinessBankAccount;
}
public int getNumberOfEmployee() {
return numberOfEmployee;
}
public void setNumberOfEmployee(int numberOfEmployee) {
this.numberOfEmployee = numberOfEmployee;
}
public SelfEmployed(double businessCapital, double averageLastBusinessBankAccount, int numberOfEmployee, String firstName, String lastName, int numberOfyear,String companyName, DateOfBirth dob, double averageLastSixthMonBalance){
super(firstName,lastName,numberOfyear,companyName,dob,averageLastSixthMonBalance);
this.businessCapital = businessCapital;
this.averageLastBusinessBankAccount = averageLastBusinessBankAccount;
this.numberOfEmployee = numberOfEmployee;
}
public String toString(){
return "SelfEmployed:[ firstName: " + firstName + " , lastName: " + lastName + ", numberOfyear: " + numberOfyear + ", companyName: " + companyName + ", dob: " + dob + ",averageLastSixthMonBalance: " + averageLastSixthMonBalance + ", businessCapital: " + businessCapital + ", averageLastBusinessBankAccount: " + averageLastBusinessBankAccount + " ,numberOfEmployee: " + numberOfEmployee;
}
}
class Employed extends Applicant{
double salary;
String title;
public double getSalary() {
return salary;
}
public void setSalary(double salary) {
this.salary = salary;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Employed(double salary, String title, String firstName, String lastName, int numberOfyear,String companyName, DateOfBirth dob, double averageLastSixthMonBalance){
super(firstName,lastName,numberOfyear,companyName,dob,averageLastSixthMonBalance);
this.salary = salary;
this.title = title;
}
public String toString(){
return "Employed:[ firstName: " + firstName + " , lastName: " + lastName + ", numberOfyear: " + numberOfyear + ", companyName: " + companyName + ", dob: " + dob + ",averageLastSixthMonBalance: " + averageLastSixthMonBalance + ", salary: " + salary + ", title: " + title;
}
}
class DateOfBirth {
int day;
int month;
int year;
public DateOfBirth(int day, int month, int year){
this.day = day;
this.month = month;
this.year = year;
}
public String toString(){
return day + "/" + month + "/" + year;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.