# Golang example How to calculate future compound interest It is a short tutorial about how to calculate compound interest in the go language.

## Golang Compound Interest example program

Compound interest is used in the calculating value of an amount in investment and finance domains.

Compound interest is an interest applied to the principal, the period for the period. In mathematical terms, Compound interest has a formula as seen below.

``````Future Compound Interest Amount = principal × ((interest rate/100)+1) power of number
Interest Amount = Future Compound Interest Amount - Amount``````
• principal: principal amount
• Interest rate: It is a percentage value (%)
• the number is years in a period

Let’s write a program to calculate compound interest in the go language In a program code,

• User enters an input of principal amount, interest, and Period from the console
• save all these values in a temporary variable
• Calculate future amount and compound interest amount using the above formula
• Finally, print the result

Here is the golang program code to calculate simple interest.

``````package main

import (
"fmt"
)

func main() {
var principal, interest, period, total compountInterest float64;
fmt.Scanln( & principal)
fmt.Scanln( & interest)

fmt.Scanln( & period)

futureAmount = principal * (math.Pow((1 + interest / 100), period))
compountInterest = futureAmount - principal

fmt.Println("\n Compound Interest  Amount: ", compountInterest)
fmt.Println("\n Total  Future Amount: ", futureAmount)

}``````

Output:

``````Please enter principal amount: 10000