CODE:

import java.util.Scanner;
 
class EMPLOYEE {
    String name;
    int id;
 
    EMPLOYEE(String name, int id) {
        this.name = name;
        this.id = id;
    }
 
    void calculateSalary() {
        System.out.println("Salary calculation not defined.");
    }
 
    void displayEmployeeDetails() {
        System.out.println("Name: " + name);
        System.out.println("ID: " + id);
    }
}
 
class PartTimeEmp extends EMPLOYEE {
    int hoursWorked;
    static final double hourlyRate = 150.0;
 
    PartTimeEmp(String name, int id, int hoursWorked) {
        super(name, id);
        this.hoursWorked = hoursWorked;
    }
 
    @Override
    void calculateSalary() {
        double salary = hoursWorked * hourlyRate;
        System.out.println("Salary: " + salary);
    }
 
    @Override
    void displayEmployeeDetails() {
        super.displayEmployeeDetails();
        System.out.println("Type: Part-Time");
        System.out.println("Hours Worked: " + hoursWorked);
        System.out.println("Hourly Rate: " + hourlyRate);
    }
}
 
class FullTimeEmp extends EMPLOYEE {
    double bonus;
    double deductions;
    double baseSalary;
 
    FullTimeEmp(String name, int id, double baseSalary, double bonus, double deductions) {
        super(name, id);
        this.baseSalary = baseSalary;
        this.bonus = bonus;
        this.deductions = deductions;
    }
 
    @Override
    void calculateSalary() {
        double salary = baseSalary + bonus - deductions;
        System.out.println("Salary: " + salary);
    }
 
    @Override
    void displayEmployeeDetails() {
        super.displayEmployeeDetails();
        System.out.println("Type: Full-Time");
        System.out.println("Base Salary: " + baseSalary);
        System.out.println("Bonus: " + bonus);
        System.out.println("Deductions: " + deductions);
    }
}
 
public class ProblemTwo {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        System.out.print("Enter name of part-time employee: ");
        String n1 = sc.nextLine();
        System.out.print("Enter ID: ");
        int id1 = sc.nextInt();
        System.out.print("Enter hours worked: ");
        int hrs = sc.nextInt();
        PartTimeEmp p = new PartTimeEmp(n1, id1, hrs);
 
        sc.nextLine();
        System.out.print("Enter name of full-time employee: ");
        String n2 = sc.nextLine();
        System.out.print("Enter ID: ");
        int id2 = sc.nextInt();
        System.out.print("Enter base salary: ");
        double base = sc.nextDouble();
        System.out.print("Enter bonus: ");
        double b = sc.nextDouble();
        System.out.print("Enter deductions: ");
        double d = sc.nextDouble();
        FullTimeEmp f = new FullTimeEmp(n2, id2, base, b, d);
 
        EMPLOYEE ref;
 
        System.out.println("\n--- Part-Time Employee ---");
        ref = p;
        ref.displayEmployeeDetails();
        ref.calculateSalary();
 
        System.out.println("\n--- Full-Time Employee ---");
        ref = f;
        ref.displayEmployeeDetails();
        ref.calculateSalary();
    }
}

OUTPUT:

Enter name of part-time employee: Achu
Enter ID: 1 
Enter hours worked: 15
Enter name of full-time employee: Anirudh
Enter ID: 18
Enter base salary: 15000
Enter bonus: 7000
Enter deductions: 500
 
--- Part-Time Employee ---
Name: Achu
ID: 1
Type: Part-Time
Hours Worked: 15
Hourly Rate: 150.0
Salary: 2250.0
 
--- Full-Time Employee ---
Name: Anirudh
ID: 18
Type: Full-Time
Base Salary: 15000.0
Bonus: 7000.0
Deductions: 500.0
Salary: 21500.0