欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

kotlin 计算平方_Kotlin程序来计算复利

发布时间:2023/12/1 编程问答 81 豆豆
生活随笔 收集整理的这篇文章主要介绍了 kotlin 计算平方_Kotlin程序来计算复利 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

kotlin 计算平方

Compound interest is the sum of principal amount and interest of interest.

复利是本金和利息之和。

Given, principal, rate, and time, we have to calculate the Compound interest.

给定本金,利率和时间,我们必须计算复利。

Formula to calculate Compound interest is: P * (Math.pow(( 1 + R/100), T)

计算复利的公式为:P *(Math.pow((1 + R / 100),T)

Where,

哪里,

  • P is Principal amount.

    P是本金。

  • R is rate of interest per annum.

    R是每年的利率。

  • T is time in years.

    T是以年为单位的时间。

Example:

例:

Input:P = 5000R = 12T = 5Output:Compound Interest = 8811.708416000003

计算Kotlin复利的程序 (Program to calculate Compound interest in Kotlin)

package com.includehelpimport java.util.*//Main Function , Entry point of Program fun main(args: Array<String>) {//Input Streamval scanner = Scanner(System.`in`)//Input Amountprint("Enter Principal Amount : ")val principalAmount = scanner.nextDouble()//Input Interest Rateprint("Enter Rate of Interest : ")val rateOfInterest = scanner.nextDouble()//Input time in yearsprint("Enter Time : ")val time = scanner.nextDouble()//Calculate Compound Interestval compoundInterest = principalAmount.toDouble() * Math.pow((1 + rateOfInterest.toDouble()/100.00),time.toDouble())//Print Compound Interestprintln("Compound Interest is :$compoundInterest") }

Output

输出量

Enter Principal Amount : 5000 Enter Rate of Interest : 12 Enter Time : 5 Compound Interest is :8811.708416000003

翻译自: https://www.includehelp.com/kotlin/calculate-compound-interest.aspx

kotlin 计算平方

总结

以上是生活随笔为你收集整理的kotlin 计算平方_Kotlin程序来计算复利的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。