JustPaste
HomeCategoriesAboutDonateContactTerms of UsePrivacy Policy
JustPaste

Free online notepad — write and share instantly

Navigate

  • Home
  • Timeline
  • Categories

Info

  • About
  • Donate
  • Contact

Legal

  • Terms of Use
  • Privacy Policy

© 2026 JustPaste.app. All rights reserved.

Made with ♥ by JustPaste

Untitled Page | JustPaste.app
about 1 month ago2 views
👨‍💻Programming
package payslip;

import java.util.Scanner;

class Employee {
    int empId;
    String empName;

    void getEmployeeDetails() {
        Scanner sc = new Scanner(System.in);

        System.out.print("Enter Employee ID: ");
        empId = sc.nextInt();
        sc.nextLine();

        System.out.print("Enter Employee Name: ");
        empName = sc.nextLine();
    }
}

class Salary extends Employee {
    double basic, hra, da, grossSalary;

    void getSalaryDetails() {
        Scanner sc = new Scanner(System.in);

        System.out.print("Enter Basic Salary: ");
        basic = sc.nextDouble();

        System.out.print("Enter HRA: ");
        hra = sc.nextDouble();

        System.out.print("Enter DA: ");
        da = sc.nextDouble();

        grossSalary = basic + hra + da;
    }

    void generatePayslip() {
        System.out.println("\n===== EMPLOYEE PAYSLIP =====");
        System.out.println("Employee ID   : " + empId);
        System.out.println("Employee Name : " + empName);
        System.out.println("Basic Salary  : " + basic);
        System.out.println("HRA           : " + hra);
        System.out.println("DA            : " + da);
        System.out.println("Gross Salary  : " + grossSalary);
        System.out.println("============================");
    }
}

public class PaySlip {
    public static void main(String[] args) {
        Salary s = new Salary();

        s.getEmployeeDetails();
        s.getSalaryDetails();
        s.generatePayslip();
    }
}
← Back to timeline