Skip to content
doubtly

1 answer

Best answer

Answer: Gross salary = Basic + DA + HRA, where DA = Basic × DA% / 100 and HRA = Basic × HRA% / 100.

Steps

  1. Read name, company, basic salary and the DA and HRA percentages using float(), so values like 12.5 work.
  2. Compute DA and HRA as percentages of basic.
  3. Gross = Basic + DA + HRA; print rounded to 2 decimals. (Do not convert to int, which would cut off the paise and the decimal part of the percentages.)

Program

print("Employee Gross Salary Calculator")

name = input("Enter name of employee: ")
company = input("Enter name of company: ")
basic = float(input("Enter basic salary: "))
da_pct = float(input("Enter DA percentage: "))
hra_pct = float(input("Enter HRA percentage: "))

da = basic * da_pct / 100
hra = basic * hra_pct / 100
gross = basic + da + hra

print("\nSalary slip of", name, "-", company)
print("Basic salary :", round(basic, 2))
print("DA           :", round(da, 2))
print("HRA          :", round(hra, 2))
print("Gross salary :", round(gross, 2))

Sample run (python3)

Employee Gross Salary Calculator
Enter name of employee: Ravi Patil
Enter name of company: ABC Ltd
Enter basic salary: 25000
Enter DA percentage: 12.5
Enter HRA percentage: 20

Salary slip of Ravi Patil - ABC Ltd
Basic salary : 25000.0
DA           : 3125.0
HRA          : 5000.0
Gross salary : 33125.0

Check: DA = 25000 × 12.5 / 100 = 3125, HRA = 25000 × 20 / 100 = 5000, Gross = 25000 + 3125 + 5000 = 33125.

Doubtly · 16 Apr 2023 Report
Was this answer helpful?

Your answer

Log in or create a free account to answer this question.