This Go program uses the Else If statement to calculate the employee’s gross salary. Please replace the HRA and DA percentages as you need.
package main import "fmt" func main() { var basicSal, hra, da, grossSal float64 fmt.Print("Enter the Employee Basic Salary = ") fmt.Scanln(&basicSal) if basicSal <= 10000 { hra = (basicSal * 8) / 100 da = (basicSal * 10) / 100 } else if basicSal <= 20000 { hra = (basicSal * 16) / 100 da = (basicSal * 20) / 100 } else { hra = (basicSal * 24) / 100 da = (basicSal * 30) / 100 } grossSal = basicSal + hra + da fmt.Println("The Gross Salary of this Employee = ", grossSal) }

Golang Program to Calculate Employee Salary
This Go example allows users to enter the basic salary, HRA, and DA percentages to find the gross salary.
package main import "fmt" func main() { var basicSal, hra, hraPer, da, daPer, grossSal float64 fmt.Print("Enter the Employee Basic Salary = ") fmt.Scanln(&basicSal) fmt.Print("Enter the Employee HRA Percentage = ") fmt.Scanln(&hraPer) fmt.Print("Enter the Employee DA Percentage = ") fmt.Scanln(&daPer) hra = basicSal * (hraPer / 100) da = basicSal * (daPer / 100) grossSal = basicSal + hra + da fmt.Println("The HRA of this Employee = ", hra) fmt.Println("The DA of this Employee = ", da) fmt.Println("The Gross Salary of this Employee = ", grossSal) }

In this Go program, we allow the users to enter the fixed DA, and HRA amounts to find the gross salary.
package main import "fmt" func main() { var basicSal, hra, da, grossSal float64 fmt.Print("Enter the Employee Basic Salary = ") fmt.Scanln(&basicSal) fmt.Print("Enter the Employee HRA Amount = ") fmt.Scanln(&hra) fmt.Print("Enter the Employee DA Amount = ") fmt.Scanln(&da) grossSal = basicSal + hra + da fmt.Println("The Gross Salary of this Employee = ", grossSal) }
