Go language program to calculate interest

Views: 140   

Following program shows you how to calculate interest.
In this program we get investment, interest rate and time from user and calculate interest using following formula
Interest = investment X interestRate X time / 100

package main

import "fmt"

func main() {

  var investment int
  var interestRate int
  var time int
  var interest int
  fmt.Println("Enter investment:")
  fmt.Scanf("%d", &investment)
  fmt.Println("Enter interest rate:")
  fmt.Scanf("%d", &interestRate)
  fmt.Println("Enter number of years:")
  fmt.Scanf("%d", &time)
  interest = investment * interestRate * time / 100
  fmt.Println("Interest amount is: " , interest)


Enter investment:
Enter interest rate:
Enter number of years:
Interest amount is:  1440000
On By