Write a program in python to enter Employee details as name, Basic salary,Deductions, bonus. Calculate the total salary that is totalsal =basic+ bonus - deductions
Answers
Python program to calculate total salary can be defined as below:
Output:
Enter employee name: DEV
Enter Basic salary in rupee: 15000
Enter Deduction amount in rupee: 2500
Enter the bonus amount in rupee: 1200
DEV total salary 13700.0
Explanation:
Program:
name=input('Enter employee name: ') #input name in name variable
basic_salary=float(input('Enter Basic salary in rupee: ')) #input basic salary in basic_salary variable
deduction=float(input('Enter Deduction amount in rupee: '))#input deduction amount in deduction variable
bonus=float(input('Enter the bonus amount in rupee: ')) #input bonus amount in bonus variable
totalsal=basic_salary+bonus-deduction #Calculate totalsal
print(name,'total salary',totalsal) #print name and total salary
explanation of program as follows:
- In the above python code, five variable " name, basic_salary, deduction, bonus, and totalsal" is defined, in which name variable take string value and other three variables "basic_salary, deduction, and bonus" use float value.
- All the above variable uses input function, that takes value from the user end, and the "totalsal" variable calculates total salary and prints its value with employee name.
Learn more:
- Calculate the sum of two number: https://brainly.in/question/11062269
- Python program: https://brainly.in/question/14337377
Answer:
Include appropriate getters and setters method in Employee class. Write the following method in the Employee class: public void calculateNetSalary(int pfpercentage) - This method should take PF percentage as argument. Deduct the PF amount from the salary and set the netSalary.
Create a Main class which has the main method which invokes the method to get the input and prints the details as shown in the sample.
Also write a method :
public static Employee getEmployeeDetails() - which gets the employee details - id, name and salary, and returns the employee object.
public static int getPFPercentage() - which gets the PF percentage and returns the same
In the main method invoke the above two methods, and then call the calculateNetSalary method in Employee class and print the output as shown below.
Sample Input 1:
Enter Id: 101 Enter Name: Vivek Enter salary: 20000 Enter PF percentage: 7
Sample Output 1:
Id : 101
Name : Vivek
Salary : 20000.0
Net Salary : 18600.0