THE BEST NEWSLETTER ANYWHERE

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

It is a short tutorial about how to calculate simple interest using golang

Simple interest is an interest applied to the principal amount applies to the rate of interest in a period for some time.

Normally, To calculate simple interest in mathematical terms, We have used the formula.

```
Simple Interest=P x N x R/100
```

- P is the principal amount
- N is the Number of months
- R is the interest rate

In a program code,

- Take input of principal amount, interest, and Period
- Store all this in a variables
- Calculate 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 float64;
fmt.Print("Please enter principal amount: ")
fmt.Scanln(&principal)
fmt.Print("Please enter Interest Rate: ")
fmt.Scanln(&interest)
fmt.Print("Please enter period: ")
fmt.Scanln(&period)
total= (principal* interest* period) / 100
fmt.Println("\nSimple Interest Amount: ", total)
fmt.Println("\n Total Amount: ", amount+total)
}
```

Output:

```
Please enter principal amount: 10000
Please enter Interest Rate: 24
Please enter the period: 1
Simple Interest Amount: 2400
Total Amount: 12400
```

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

Calculate the simple interest and returns total amount.

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

THE BEST NEWSLETTER ANYWHERE

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.

🧮 Tags

Recent posts

Top 10 ways to get the first element from an array in javascript with example Multiple ways to sort array JSON object with key date field in javascript Multiple ways to create an array with random values in javascript Javascript how to remove leading zero from a string number javascript How to convert/parse String object to JSON objectRelated posts