JAVA-SE-Tutorial-codeswithpankaj
JAVA-SE-Tutorial-codeswithpankaj copied to clipboard
Advanced Level Assignment: Salary System in Java
Assignment Questions
-
Class Design:
- Design an
Employee
class to store the employee's details:- Name
- ID
- Basic Salary
- Designation
- Department
- Design an
-
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
- Add methods to calculate the following components of the salary:
-
Input Handling:
- Write a method to take input for employee details and basic salary.
- Ensure the input salary is a positive number.
-
Output Handling:
- Write a method to display the employee details and all components of the salary, including Gross Salary and Net Salary.
-
Validation:
- Implement input validation to ensure all entered details are valid (e.g., non-empty name, positive salary).
-
Formatting:
- Ensure the output is well-formatted and readable.
-
Main Method:
- Write the main method to create an
Employee
object, take input, perform calculations, and display the salary details.
- Write the main method to create an
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.