# Go Program to Calculate Employee Salary

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)
}```
``````SureshMac:Goexamples suresh\$ go run empSal1.go
Enter the Employee Basic Salary = 8000
The Gross Salary of this Employee =  9440
SureshMac:Goexamples suresh\$ go run empSal1.go
Enter the Employee Basic Salary = 18000
The Gross Salary of this Employee =  24480
SureshMac:Goexamples suresh\$ go run empSal1.go
Enter the Employee Basic Salary = 35000
The Gross Salary of this Employee =  53900
SureshMac:Goexamples suresh\$ ``````

## 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)
}```
``````SureshMac:Goexamples suresh\$ go run empSal2.go
Enter the Employee Basic Salary = 35000
Enter the Employee HRA Percentage = 25
Enter the Employee DA Percentage = 35
The HRA of this Employee =  8750
The DA of this Employee =  12250
The Gross Salary of this Employee =  56000``````

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)
}```