Tutorial Gateway

  • C
  • C#
  • Python
  • SQL
  • Java
  • JS
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • Alteryx
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Go Programs
    • Python Programs
    • Java Programs
  • MySQL

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)
}
Go Program to Calculate Employee Salary 1

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)
}
Go Program to Calculate Employee Salary 2

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)
}
Golang Program to find Employee Salary 3

Filed Under: Go Examples

  • Golang Hello World Program
  • Go Add Two Number
  • Go Calculate Electricity Bill
  • Go Calculate Employee Salary
  • Go Compound Interest
  • Go Count Digits in a Number
  • Go Count Total Notes in Amount
  • Go Cube of a Number
  • Go Even or Odd
  • Go Factorial of a Number
  • Go First Digit of a Number
  • Go Generic Root of a Number
  • Go Largest of Three Numbers
  • Go Leap year Program
  • Go Reverse Natural Numbers
  • Go Roots of a Quadratic Equation
  • Go Multiplication Table
  • Go Number divisible by 5 and 11
  • Go NCR Factorial of a Number
  • Go Positive or Negative
  • Go Power of a Number
  • Go Print Natural Numbers
  • Go Profit or Loss
  • Go Print 1 to 100 without loop
  • Go Program to Print 1 to 100
  • Go Product of Digits in a Number
  • Go Palindrome Number Program
  • Go Print Even Numbers
  • Go Print Odd Numbers
  • Go Factors of a Number
  • Go Perfect Number
  • Go Prime Number
  • Go Reverse a Number
  • Go Simple Interest
  • Go Square of a Number
  • Go Square root of a Number
  • Go Sum of Digits in a Number
  • Go Sum & Avg of Natural Nums
  • Go Sum of Even Numbers
  • Go Sum of Odd Numbers
  • Go Sum of Even and Odd
  • GoSwap Two Numbers
  • Go Sphere Vol & Surface Area
  • Go Cylinder Vol & Surface Area
  • Go Cuboid Vol & Surface Area
  • Go Cube Volume & Surface Area
  • Go Cone Volume & Surface Area
  • Go Arithmetic Operation on Array
  • Go Count Duplicates in Array
  • Go Even Numbers in Array
  • Go Largest Array Item
  • Go Largest & Smallest in Array
  • Go Negative Numbers in Array
  • Go Odd Numbers in an Array
  • Go Positive Numbers in Array
  • Go Pos & Neg in Separate Array
  • Go Reverse an Array
  • Go Search for Array Items
  • Go Smallest Array Item
  • Go Character is a Digit
  • Go Convert Character to Lower
  • Go Convert Character to Upper
  • Go ASCII Value of Character
  • Go ASCII Values of All Characters
  • Go Character is a Lowercase
  • Go Character is an Alphabet
  • Go Character is an Uppercase
  • Go Char Vowel or Consonant
  • Go Print Alphabets from a to z
  • Go Print Alphabets from A to Z
  • Go Matrix Arithmetic Operations
  • Go Program to Add Two Arrays
  • Go Matrix Multiplication Program
  • Go Program to Add Two Matrices
  • Go Identity Matrix
  • Go Sparse Matrix
  • Go Array Multiplication Program
  • Go Program to Print Array Items
  • Go Program to Print Matrix Items
  • Go Matrix Determinant
  • Go Sum of Each Matrix Column
  • Go Sum of Each Matrix Row
  • Go Sum of Matrix Diagonal
  • Go Sum of Matrix Lower Triangle
  • Go Sum of Matrix Upper Triangle
  • Go Print Matrix Upper Triangle
  • Go Print Matrix Lower Triangle
  • Go Sum of Matrix Each Row & Col
  • Go Sum of Matrix Opp Diagonal
  • Go Interchange Matrix Diagonals
  • Go Scalar Matrix Multiplication
  • Go Odd Index Position Array Item
  • Go Even Index Position Array Item
  • Go Symmetric Matrix
  • Go Two Matrixes are Equal
  • Go Count Positive & Neg in Array
  • Go Count Even and Odd in Array
  • Go Transpose a Matrix

Copyright © 2021ยท All Rights Reserved by Suresh.
About | Contact | Privacy Policy