Program to calculate simple interest in golang

Go Program to calculate simple interest. Here more solutions.

package main
import "fmt"

//  Golang program for
//  Calculate simple interest

// Method which is take three parameters
// And calculates that simple interest
// Here time is form in year
// rate is form of annual interest rate
func simpleInterest(principle, time, rate float64) {
    // Display parameters values
    fmt.Println("Principle : ",principle);
    fmt.Println("Time : ",time);
    fmt.Println("Rate : " ,rate);
    // Calculate interest
    var  amount  float64 = (principle * time * rate) / 100;
    // Display amount
    fmt.Println("Simple Interest : " ,amount, "\n");
}

func main() {
    // Test Cases
    simpleInterest(1500, 3, 7.3);
    simpleInterest(170.4, 7, 3.4);
 }

Output

Principle :  1500
Time :  3
Rate :  7.3
Simple Interest :  328.5 

Principle :  170.4
Time :  7
Rate :  3.4
Simple Interest :  40.55519999999999 



Comment

Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.

New Comment







© 2022, kalkicode.com, All rights reserved