Golang 程式,計算給定所有必要值的單利
步驟
- 讀取本金、利率和時間的數值。
- 使用公式計算單利。
- 列印計算得出的利息值。
| 輸入本金:200 輸入時間(年):5 輸入利率:5 單利是:50 | 輸入本金:70,000 輸入時間(年):1 輸入利率:4 單利是:2,800 |
說明
- 使用者必須輸入本金、利率和時間的值。
- 公式:(amount*time*rate)/100 用於計算單利。
- 之後列印單利。
示例
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)
}輸出
Enter the principal amount: 10000 Enter the time in years: 5 Enter the rate: 5 The simple interest is: 2500
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP