Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Golang Program to Compute Simple Interest Given all the Required Values
Steps
- Read the values for principal amount, rate and time.
- Using the formula, compute the simple interest.
- Print the value for the computed interest.
| Enter the principal amount: 200 Enter the time(years): 5 Enter the rate: 5 The simple interest is: 50 |
Enter the principal amount: 70000 Enter the time(years): 1 Enter the rate: 4 The simple interest is: 2800 |
Explanation
- User must enter the values for the principal amount, rate and time.
- The formula: (amount*time*rate)/100 is used to compute the simple interest.
- The simple interest is later printed.
Example
package main
import "fmt"
func main() {
var principal, time, rate int
fmt.Print("Enter the principal amount: ")
fmt.Scanf("%d", &principal)
fmt.Print("Enter the time in years: ")
fmt.Scanf("%d", &time)
fmt.Print("Enter the rate: ")
fmt.Scanf("%d", &rate)
simpleInterest :=(principal*time*rate)/100
fmt.Println("The simple interest is: ", simpleInterest)
}
Output
Enter the principal amount: 10000 Enter the time in years: 5 Enter the rate: 5 The simple interest is: 2500
Advertisements
