Q:

Kotlin program to calculate simple interest

0

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

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now