# Golang How to calculate future compound interest in Golang

This is an short tutorial about how to calculate compound interest in go language

## what is Compound Interest with formula

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

Complex interest is a an interest applied to principal, period for period of time. In mathematical terms, Compound interest has a formula

``````
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 an percentage value (%)
• number is an period in years

Let’s write program to calculate compound interest in golanguage In a program code,

• User enter an input of principal amount, interest and Period from console
• save all these values in a temparory 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("\nCompound Interest  Amount: ", compountInterest )
fmt.Println("\n Total  Future Amount: ", futureAmount)

}
``````

Output:

``````Please enter principal amount: 10000
nCompound Interest  Amount: 72850
Total  Future Amount: 1.797010299914431e+61
``````

This program takes input - principal, rate of interest and period in years and stored these values in a variable.

Calculated the future and compound interest and returns total amount.

## Conclusion

In this example, You learned calculate compound interest principal amount in Go language.

Join 6,000 subscribers and get a daily digest of full stack tutorials delivered to your inbox directly.No spam ever. Unsubscribe any time.

Similar Posts
Subscribe
You'll get a notification every time a post gets published here.

Related posts