Java Program to Calculate Simple Interest

JavaObject Oriented ProgrammingProgramming

In this article, we will understand how to calculate the simple interest. Simple Interest is calculated using the following formula, If Principal = P, Rate = R% per annum, Time = T years:

Simple Interest (S.I) = P * T * R / 100

Simple Interest − The percentage interest on total principal amount. Returns are less compared to Compound Interest.

Below is a demonstration of the same −


Suppose our input is −

Enter a Principle number : 100000
Enter a Interest rate : 5
Enter a Time period in years : 2


The desired output would be −

Simple Interest : 1000


Step 1 – START
Step 2 – Declare four float values principle, rate, time, simple_interest
Step 3 – Read values of principle, rate, time, from the user
Step 4 – Perform "(principle*rate*time)/100" to calculate the simple interest and store it in a
simple_interest variable
Step 8 – Display simple_interest
Step 10 – STOP

Example 1

Here, the input is being entered by the user based on a prompt. You can try this example live in ourcoding ground tool run button.

import java.util.Scanner;
public class SimpleInterest{
   public static void main (String args[]){
      float principle, rate, time, simple_interest;
      System.out.println("Required packages have been imported");
      Scanner my_scanner = new Scanner(;
      System.out.println("A my_scanner object has been defined ");
      System.out.print("Enter a Principle number : ");
      principle = my_scanner.nextInt();
      System.out.print("Enter a Interest rate : ");
      rate = my_scanner.nextInt();
      System.out.print("Enter a Time period in years : ");
      time = my_scanner.nextInt();
      simple_interest = (principle*rate*time)/100;
      System.out.println("The Simple Interest is : " + simple_interest);


Required packages have been imported
A Scanner object has been defined
Enter a Principle number : 10000
Enter a Interest rate : 5
Enter a Time period in years : 2
The Simple Interest is : 1000.0

Example 2

Here, the integer has been previously defined, and its value is accessed and displayed on the console.

public class SimplInterest{
   public static void main (String args[]){
      float principle, rate, time, simple_interest;
      principle = 100000;
      rate = 5;
      time = 2;
      System.out.printf("The Principle amount is %f \nThe interest rate is %f \nThe time period in years is %f " , principle, rate, time);
      simple_interest = (principle*rate*time)/100;
      System.out.println("\nThe Simple Interest is: " + simple_interest);


The Principle amount is 100000.000000
The interest rate is 5.000000
nThe time period in years is 2.000000
The Simple Interest is: 1000.0
Updated on 21-Feb-2022 10:32:06