Write a Java Program to calculate simple interest.

Write a Java Program to calculate simple interest.

Write a Java Program to calculate simple interest.

Simple Interest Formula

Simple Interest = (P × R × T)/100

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

For example: Let’s say a man deposit 2000 INR in bank account at a interest rate of 6% per annum for 3 years, calculate the simple interest at the end of 3 years.

Simple interest = 2000*6*3/100 = 360 INR

In the following example we are taking the values of p, r and t from user and then we are calculating the simple interest based on entered values.

import java.util.Scanner;
public class JavaExample
{
    public static void main(String args[]) 
    {
        float p, r, t, sinterest;
        Scanner scan = new Scanner(System.in);
        System.out.print("Enter the Principal : ");
        p = scan.nextFloat();
        System.out.print("Enter the Rate of interest : ");
        r = scan.nextFloat();
        System.out.print("Enter the Time period : ");
        t = scan.nextFloat();
        scan.close();
        sinterest = (p * r * t) / 100;
        System.out.print("Simple Interest is: " +sinterest);
    }
}

Output:

Enter the Principal : 2000
Enter the Rate of interest : 6
Enter the Time period : 3
Simple Interest is: 360.0

 

Author Biography.

Lokesh Gupta
Lokesh Gupta

Overall 3+ years of experience as a Full Stack Developer with a demonstrated history of working in the information technology and services industry. I enjoy solving complex problems within budget and deadlines putting my skills on PHP, MySQL, Python, Codeigniter, Yii2, Laravel, AngularJS, ReactJS, NodeJS to best use. Through Knowledge of UML & visual modeling, application architecture design & business process modeling. Successfully delivered various projects, based on different technologies across the globe.

News & Blogs

e58d929bc4999ddd2bd803bd94eb1cac.png

What It Was Like to Write a Full Blown Flutter App

1. Porting an iOS App to Flutter Since my last post about Flutter months ago, I felt that the lo...

f62dbc1a41f2267ac3920998ea272871.jpg

You Don’t Need Loops in JavaScript

1. To Loop Through All Elements and Get an new modified array Using loop: var names = ["Jack",...

ebd1a2ed9fd0a6e8dd70b6097706cea5.jpeg

How to Create a Chatbot Using Dialogflow

Chatbots are artificially intelligent programs by which we can make our websites more interactive...