kotlin创建静态单利_Kotlin程序来计算单利

kotlin创建静态单利

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

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

Formula to calculate simple interest is: (P × R × T)/100

计算单利的公式为:(P×R×T)/ 100

Where,

哪里,

  • P is Principal amount.

    P是本金。

  • R is rate of interest per annum.

    R是每年的利率。

  • T is time in years.

    T是以年为单位的时间。

Example:

例:

    Input:
    P = 5000
    R = 12
    T = 2

    Output:
    Simple Interest = 1200.0

计算对Kotlin的简单兴趣的程序 (Program to calculate simple interest in Kotlin)

package com.includehelp

import java.util.*

//Main Function , Entry point of Program
fun main(args: Array<String>) {

    //Input Stream
    val scanner = Scanner(System.`in`)

    //Input Amount
    print("Enter Principal Amount : ")
    val principalAmount = scanner.nextDouble()

    //Input Interest Rate
    print("Enter Rate of Interest : ")
    val rateOfInterest = scanner.nextDouble()

    //Input time in years
    print("Enter Time : ")
    val time = scanner.nextInt()

    //Calculate Simple Interest
    val simpleInterest = (principalAmount*rateOfInterest*time)/100

    //Print Simple Interest
    println("Simple Interest is :$simpleInterest")
}

Output

输出量

Run 1:
Enter Principal Amount : 5000
Enter Rate of Interest : 12
Enter Time : 2
Simple Interest is :1200.0
---
Run 2:
Enter Principal Amount : 500.60
Enter Rate of Interest : 12.56
Enter Time : 5
Simple Interest is :314.37680000000006


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

kotlin创建静态单利

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值