Program to Enter Basic Salary and Calculate Gross Salary of an Employee

Python Program to Enter Basic Salary and Calculate Gross Salary of an Employee

In the previous article, we have discussed Python Program to Check Duck Number
Gross Salary:

It denotes the amount paid out to an individual prior to any voluntary or mandatory deductions. As a result, it is the total pay received by an employee before taxes and other deductions. Gross salary includes all sources of income and is not limited to only cash income. As a result, it includes any benefits or services received by an employee. The salary that an employee receives, on the other hand, is the net salary after deductions.

House rent allowance (HRA):

House rent allowance, or HRA, is a salary component that covers employees’ housing expenses.

Formula to calculate the Gross Salary :

Gross salary equals the sum of the basic salary plus the HRA and any other allowances.

Gross salary = Basic salary + House Rent Allowance + Other Allowances

Gross salary =basic + da + hr + da_on_ta

da=(15*basic)/100

hr=(10*basic)/100

da on ta=(3*basic)/100

Examples:

Example1:

Input:

Given Basic salary = 23000

Output:

The Employee's Gross salary from the given basic salary { 23000 } = 29440.0

Example2:

Input:

Given Basic salary = 18000

Output:

The Employee's Gross salary from the given basic salary { 18000 } = 23040.0

Program to Enter Basic Salary and Calculate Gross Salary of an Employee  in Python

Below are the ways to calculate the Gross salary from the given basic salary :

Method #1: Using Mathematical Formula (Static Input)

Approach:

  • Give the basic salary as static input and store it in a variable.
  • Calculate the value of da from the above given mathematical formula and store it in another variable.
  • Calculate the value of hr from the above given mathematical formula and store it in another variable.
  • Calculate the value of da-on-ta from the above given mathematical formula and store it in another variable.
  • Calculate the gross salary using the above given mathematical formula and store it in another variable.
  • Print the Gross salary of an employee from the given basic salary.
  • The Exit of the program.

Below is the implementation of the above given approach:

# Give the basic salary as static input and store it in a variable.
gvn_basc_sal = 23000
# Calculate the value of da from the above given mathematical formula and store
# it in another variable.
gvn_da = (float)(15 * gvn_basc_sal) / 100.0
# Calculate the value of hr from the above given mathematical formula and store
# it in another variable.
gvn_hr = (float)(10 * gvn_basc_sal) / 100.0
# Calculate the value of da-on-ta from the above given mathematical formula and store
# it in another variable.
gvn_da_on_ta = (float)(3 * gvn_basc_sal) / 100.0
# Calculate the gross salary using the above given mathematical formula and store
# it in another variable.
gros_sal = gvn_basc_sal + gvn_da + gvn_hr + gvn_da_on_ta
# Print the Gross salary of an employee from the given basic salary.
print(
    "The Employee's Gross salary from the given basic salary {", gvn_basc_sal, "} =", gros_sal)

Output:

The Employee's Gross salary from the given basic salary { 23000 } = 29440.0

Method #2: Using Mathematical Formula (User Input)

Approach:

  • Give the basic salary as user input using the float(input()) function and store it in a variable.
  • Calculate the value of da from the above given mathematical formula and store it in another variable.
  • Calculate the value of hr from the above given mathematical formula and store it in another variable.
  • Calculate the value of da-on-ta from the above given mathematical formula and store it in another variable.
  • Calculate the gross salary from the above given mathematical formula and store it in another variable.
  • Print the Gross salary of an employee from the given basic salary.
  • The Exit of the program.

Below is the implementation:

# Give the basic salary as user input using the float(input()) function and
# store it in a variable.
gvn_basc_sal = float(input("Enter some random Number = "))
# Calculate the value of da from the above given mathematical formula and store
# it in another variable.
gvn_da = (float)(15 * gvn_basc_sal) / 100.0
# Calculate the value of hr from the above given mathematical formula and store
# it in another variable.
gvn_hr = (float)(10 * gvn_basc_sal) / 100.0
# Calculate the value of da-on-ta from the above given mathematical formula and store
# it in another variable.
gvn_da_on_ta = (float)(3 * gvn_basc_sal) / 100.0
# Calculate the gross salary using the above given mathematical formula and store
# it in another variable.
gros_sal = gvn_basc_sal + gvn_da + gvn_hr + gvn_da_on_ta
# Print the Gross salary of an employee from the given basic salary.
print(
    "The Employee's Gross salary from the given basic salary {", gvn_basc_sal, "} =", gros_sal)

Output:

Enter some random Number = 50000
The Employee's Gross salary from the given basic salary { 50000.0 } = 64000.0

Explore more instances related to python concepts from Python Programming Examples Guide and get promoted from beginner to professional programmer level in Python Programming Language.