Go Program to calculate Compound Interest

Write a Go Program to calculate Compound Interest. This golang program allows the user to enter the principal amount, totals years, and interest rates and then find the Compound Interest.

  • Future Compound Interest =  principal amount * (1 + interest rates)years
  • Compound Interest =  Future Compound Interest – principal amount
package main

import (
    "fmt"
    "math"
)

func main() {

    var Pamount, InterestRate, timePeriod, ciFuture, compoundI float64

    fmt.Print("Enter the Total or Principal Amount = ")
    fmt.Scanln(&Pamount)

    fmt.Print("Enter the Interest Rate = ")
    fmt.Scanln(&InterestRate)

    fmt.Print("Enter the Total number of Years = ")
    fmt.Scanln(&timePeriod)

    ciFuture = Pamount * (math.Pow((1 + InterestRate/100), timePeriod))
    compoundI = ciFuture - Pamount

    fmt.Println("\nThe Compound Interest  = ", compoundI)
    fmt.Println("The Future Compound Interest  = ", ciFuture)
}
Go Program to calculate Compound Interest 1

About Suresh

Suresh is the founder of TutorialGateway and a freelance software developer. He specialized in Designing and Developing Windows and Web applications. The experience he gained in Programming and BI integration, and reporting tools translates into this blog. You can find him on Facebook or Twitter.