java Miraki Evening Institute has been offering various CSEC

java

Miraki Evening Institute has been offering various CSEC subjects to the entire Caribbean population for numerous years. There success rate is the best in the region and as such has seen an exponential growth in stakeholder interest. The managers and owners are seeking to modernize the operations of the institution. One such modernization initiative is to keep track of Employees, Students and visitors. The address for all employees and students must be recorded by the system. For an address to be valid it must have the follawing attributes, street, city and parish. See Table 1 below for the minimum details stored on each category of person Table 1 Employees First Name Last Name Gender Address Students First Name Last Name Gender Visitors First Name Last Name Date of Visit Subjects Page f af 3 There are two types of employees Regular and Teachers, express this information in an enumerated dlass. Regular employees are paid a gross of $200,000.00 monthly and teachers are paid at a rate of $3,000.00 Per hour. Teachers work a maximum 30 paid hours per week and deliver no more than 5 subjects per academic year. If a teacher is delivering more than 3 subjects s/he will receive an additional $5,000.00 weekly. If the employee is a teacher the system must cakulate and display the gross weeky amount eaned, otherwise just display the gross as stated. Create an abstract super class caled Person so that Employees, Students and Visitors can derived the common attibutes. Students and Visitors cannot be inherited by any other entity. Use an interface to dedare the follawing methods printDetails0 and printDetails(Person per). The contact details (name, telephone number and email address) for the school must also be incorporated in the interface. Use another interface to declare a method called calculateGrassSalary)This method must be implemented buy the employees entity. Not all the students pursue the same number af subjects. Some may pursue 1, 2,3, 4 or more subjects, Use regular arrays to implement this functionality. All printed output must include the institution\'s name and contact details. Crete a driver class [a class with a main method) to test the logics of your program

Solution

Below are the complete code and output of this assignment:-

Address Class

public class Address {

private String street;

private String city;

private String parish;

public String getStreet() {

return street;

}

public void setStreet(String street) {

this.street = street;

}

public String getCity() {

return city;

}

public void setCity(String city) {

this.city = city;

}

public String getParish() {

return parish;

}

public void setParish(String parish) {

this.parish = parish;

}

public Address(String street, String city, String parish) {

this.street = street;

this.city = city;

this.parish = parish;

}

}

Driver Class

import java.util.Date;

public class Driver {

@SuppressWarnings(\"deprecation\")

public static void main(String[] args) {

Date date = new Date();

date.setDate(12);

date.setMonth(12);

date.setYear(2000);

Address address = new Address(\"ABC Street\", \"New York\", \"ABC\");

Student student = new Student(\"John\", \"Romero\", Gender.MALE, date, address, 5);

student.printDetails();

Visitor visitor = new Visitor(\"Johny\", \"Bravo\");

visitor.printDetails();

address = new Address(\"DEF Street\", \"New York\", \"FRE\");

RegularEmployee regular = new RegularEmployee(\"Nancy\",\"Drew\", Gender.FEMALE, address);

regular.calculateGrossSalary();

regular.printDetails();

address = new Address(\"Wall Street\", \"London\", \"UK\");

Teacher teacher = new Teacher(\"Lara\",\"Croft\", Gender.FEMALE, address, 5);

teacher.calculateGrossSalary();

teacher.printDetails();

address = new Address(\"Golden Street\", \"New Delhi\", \"IN\");

Teacher teacher2 = new Teacher(\"Seema\",\"Gupta\", Gender.FEMALE, address, 2);

teacher2.calculateGrossSalary();

teacher2.printDetails();

}

}

Employee Class

public abstract class Employee extends Person implements SalaryInfo {

private Gender gender;

private Address address;

public Address getAddress() {

return address;

}

public void setAddress(Address address) {

this.address = address;

}

public Gender getGender() {

return gender;

}

public void setGender(Gender gender) {

this.gender = gender;

}

public Employee(String firstName, String lastName, Gender gender, Address address) {

super(firstName, lastName);

this.gender = gender;

this.address = address;

}

public abstract void calculateGrossSalary();

}

Gender enum


public enum Gender {
MALE,
FEMALE,
TRANS
}

Person

public abstract class Person {

private String firstName;

private String lastName;

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 Person(String firstName, String lastName) {

this.firstName = firstName;

this.lastName = lastName;

}

}

public interface PrintInfo {

public static final String SCHOOL_NAME = \"Miraki Evening Institute\";

public static final String PHONE_NO = \"123-456-7890\";

public static final String EMAIL_ID = \"info@abcschool.com\";

public void printDetails();

public void printDetails(Person per);

}

public class RegularEmployee extends Employee implements PrintInfo{

public RegularEmployee(String firstName, String lastName, Gender gender, Address address) {

super(firstName, lastName, gender, address);

}

@Override

public void calculateGrossSalary() {

System.out.println(\"Gross Salary: $200,000.00\");

}

@Override

public void printDetails() {

printDetails(this);

System.out.println(\"School: \"+SCHOOL_NAME);

System.out.println(\"Phone No.: \"+PHONE_NO);

System.out.println(\"Email ID: \"+EMAIL_ID);

}

@Override

public void printDetails(Person per) {

System.out.println(\"First Name: \"+per.getFirstName());

System.out.println(\"Last Name: \"+per.getLastName());

}

}


public interface SalaryInfo {
public void calculateGrossSalary();
}

import java.util.Date;

public final class Student extends Person implements PrintInfo{

private Date dateOfBirth;

private Gender gender;

private Address address;

private String[] subjects;

public Address getAddress() {

return address;

}

public void setAddress(Address address) {

this.address = address;

}

public Date getDateOfBirth() {

return dateOfBirth;

}

public void setDateOfBirth(Date dateOfBirth) {

this.dateOfBirth = dateOfBirth;

}

public Gender getGender() {

return gender;

}

public void setGender(Gender gender) {

this.gender = gender;

}

public String[] getSubjects() {

return subjects;

}

public void setSubjects(String[] subjects) {

this.subjects = subjects;

}

public Student(String firstName, String lastName, Gender gender, Date dateOfBirth, Address address, int numberOfSubjects) {

super(firstName, lastName);

this.gender = gender;

this.dateOfBirth = dateOfBirth;

this.address = address;

this.subjects = new String[numberOfSubjects];

}

@Override

public void printDetails() {

printDetails(this);

System.out.println(\"School: \"+SCHOOL_NAME);

System.out.println(\"Phone No.: \"+PHONE_NO);

System.out.println(\"Email ID: \"+EMAIL_ID);

}

@Override

public void printDetails(Person per) {

System.out.println(\"First Name: \"+per.getFirstName());

System.out.println(\"Last Name: \"+per.getLastName());

}

}

public class Teacher extends Employee implements PrintInfo{

private String[] subjects;

public Teacher(String firstName, String lastName, Gender gender, Address address, int numberOfSubjects) {

super(firstName, lastName, gender, address);

if(numberOfSubjects > 5){

numberOfSubjects = 5;

}

this.subjects = new String[numberOfSubjects];

}

@Override

public void calculateGrossSalary() {

double salary = 30.0 * 3000.0;

if (subjects.length > 3) {

salary += 5000.0;

}

System.out.println(\"Weekly Gross Salary: $\" + salary);

}

@Override

public void printDetails() {

printDetails(this);

System.out.println(\"School: \"+SCHOOL_NAME);

System.out.println(\"Phone No.: \"+PHONE_NO);

System.out.println(\"Email ID: \"+EMAIL_ID);

}

@Override

public void printDetails(Person per) {

System.out.println(\"First Name: \"+per.getFirstName());

System.out.println(\"Last Name: \"+per.getLastName());

}

}

import java.util.Date;

public final class Visitor extends Person implements PrintInfo{

private Date dateTimeOfVisit;

public Date getDateTimeOfVisit() {

return dateTimeOfVisit;

}

public void setDateTimeOfVisit(Date dateTimeOfVisit) {

this.dateTimeOfVisit = dateTimeOfVisit;

}

public Visitor(String firstName, String lastName) {

super(firstName, lastName);

}

@Override

public void printDetails() {

printDetails(this);

System.out.println(\"School: \"+SCHOOL_NAME);

System.out.println(\"Phone No.: \"+PHONE_NO);

System.out.println(\"Email ID: \"+EMAIL_ID);

}

@Override

public void printDetails(Person per) {

System.out.println(\"First Name: \"+per.getFirstName());

System.out.println(\"Last Name: \"+per.getLastName());

}

}


Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site