ADVERTISEMENT
ADVERTISEMENT

Kotlin program to calculate simple interest

Kotlin | Simple Interest: Here, we are implementing a Kotlin program to calculate the simple interest.
Submitted by IncludeHelp, on May 12, 2020

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

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

Where,

  • P is Principal amount.
  • R is rate of interest per annum.
  • T is time in years.

Example:

    Input:
    P = 5000
    R = 12
    T = 2

    Output:
    Simple Interest = 1200.0

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
ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.