JAVA-SE-Tutorial-codeswithpankaj icon indicating copy to clipboard operation
JAVA-SE-Tutorial-codeswithpankaj copied to clipboard

Advanced Level Assignment: Salary System in Java

Open Pankaj-Str opened this issue 7 months ago • 8 comments

Assignment Questions

  1. Class Design:

    • Design an Employee class to store the employee's details:
      • Name
      • ID
      • Basic Salary
      • Designation
      • Department
  2. Salary Components:

    • Add methods to calculate the following components of the salary:
      • House Rent Allowance (HRA) = 20% of Basic Salary
      • Dearness Allowance (DA) = 10% of Basic Salary
      • Provident Fund (PF) = 12% of Basic Salary
      • Medical Allowance = Fixed amount (e.g., 1500)
      • Gross Salary = Basic Salary + HRA + DA + Medical Allowance
      • Net Salary = Gross Salary - PF
  3. Input Handling:

    • Write a method to take input for employee details and basic salary.
    • Ensure the input salary is a positive number.
  4. Output Handling:

    • Write a method to display the employee details and all components of the salary, including Gross Salary and Net Salary.
  5. Validation:

    • Implement input validation to ensure all entered details are valid (e.g., non-empty name, positive salary).
  6. Formatting:

    • Ensure the output is well-formatted and readable.
  7. Main Method:

    • Write the main method to create an Employee object, take input, perform calculations, and display the salary details.

Example Input

Enter your name: Nishant Chouhan
Enter your ID: E123
Enter your Basic Salary: 50000
Enter your Designation: Software Engineer
Enter your Department: IT

Example Output

Employee Salary Details
-----------------------
Name: Nishant Chouhan
ID: E123
Designation: Software Engineer
Department: IT

Basic Salary: 50000.00
House Rent Allowance (HRA): 10000.00
Dearness Allowance (DA): 5000.00
Medical Allowance: 1500.00
Provident Fund (PF): 6000.00

Gross Salary: 66500.00
Net Salary: 60500.00

Assignment Submission

Submit the Java source code file along with a document explaining the implementation, including how the input validation was handled and how the salary components were calculated.

Pankaj-Str avatar Jul 20 '24 13:07 Pankaj-Str