Go language program to calculate interest

Views: 115   

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)
  }

Output:

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