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