Golang程序 计算单利给定所有需要的值

Golang程序 计算单利给定所有需要的值

步骤

  • 读取本金数额、利率和时间的数值。
  • 使用公式,计算单利。
  • 打印计算出的利息值。

输入本金数额。200

输入时间(年)。5

输入利率。5

单利是。50

输入本金数额。70000

输入时间(年)。1

输入利率。4

单利是:2800

解释

  • 用户必须输入本金、利率和时间的数值。
  • 计算公式如下(金额时间利率)/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

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程