Hurry! Try our new Interactive Courses for FREE. 🥳   🚀

Java Program to find Simple Interest

In this tutorial, we will learn how to find simple interest when the principal, rate of interest, and time period are given. Simple interest is the easiest method to calculate interest charges on loans. But before moving further, if you are not familiar with the concept of the arithmetic operator in java, then do check the article on Operators in Java.

Input: Enter the principal amount: 6200

Enter the rate: 11

Enter the time period: 2

Output:

Simple Interest: 1364.0

Program 1: Find the Simple Interest in Java

In this program, we will see how to find the simple interest using formula when the values are user-defined. This means, first we will first ask the user to initialize the variables, and then we will find the simple interest using the formula.

Algorithm:

  1. Start

  2. Create an instance of the Scanner class to take the input from the user.

  3. Declare variables for the principal amount, rate of interest, and time period.

  4. Ask the user to initialize these variables.

  5. Calculate the simple interest using the formula.

  6. Print the value of simple interest.

  7. Stop

Below is the Java code to find simple interest.

//Java Program to find the simple interest
import java.util.Scanner;
public class Main
{
    public static void main(String args[]) 
    {
        //Take input from the user
        //Create an instance of Scanner class
        Scanner sc = new Scanner(System.in);
        //Declare variables
        float p, r, t, si;
        System.out.println("Enter the Principal : ");
        p = sc.nextFloat();     //Initialize the variables
        System.out.println("Enter the Rate of interest : ");
        r = sc.nextFloat();     //Initialize the variables
        System.out.println("Enter the Time period : ");
        t = sc.nextFloat();     //Initialize the variables
        sc.close();
        //Calculate the simple interest
        si = (p * r * t) / 100;
        //Print the simple interest
        System.out.println("Simple Interest is: " +si);
    }
}


Enter the Principal: 2000
Enter the Rate of interest: 5
Enter the Time period: 2
Simple Interest is: 200.0

Program 2: Find the Simple Interest in Java

In this program, we will find the principal, rate of interest, and the time period when the values are pre-defined.

Algorithm:

  1. Start

  2. Declare the variables for the principal amount, rate of interest, and time period.

  3. Initialize the variables.

  4. Calculate the simple interest using the formula.

  5. Print the simple interest.

  6. Stop

Below is the Java code to find simple interest.

//Java Program to find the simple interest
import java.util.Scanner;
public class Main
{
    public static void main(String args[]) 
    {
        //Declare and Initialize the Principle, Rate and Time Period
        float P = 1500, R = 10, T = 2; 
        System.out.println("The entered principle amount is = " + P);
        System.out.println("The entered rate is = " + R);
        System.out.println("The entered time period is " + T);
  
        // Calculate simple interest 
        float SI = (P * T * R) / 100;
        //Print the simple interest 
        System.out.println("Simple interest = " + SI);  
    }
}


The entered principle amount is = 1500.0
The entered rate is = 10.0
The entered time period is 2.0
Simple interest = 300.0

Program 3: Find the Simple Interest in Java

In this program, we will find the principal, rate of interest, and time period by using a user-defined function. Here, we will use the user-defined function to calculate the simple interest.

Algorithm:

  1. Start

  2. Create an instance of the Scanner class to take the input from the user.

  3. Declare variables for the principal amount, rate of interest, and time period.

  4. Ask the user to initialize these variables.

  5. Call a method to calculate the simple interest.

  6. Use the formula to calculate the simple interest.

  7. Print the value of simple interest.

  8. Stop

Below is the Java code to find simple interest.

//Java Program to find the simple interest
import java.util.Scanner;
public class Main
{
    //User-defined program to find the simple interest
    public static float simpleInterest(float principal, float rate, float time)
    {
        float interest = (principal*rate*time)/100;
        return interest;
    }

    public static void main(String args[]) 
    {
        //Take input from the user
        //Create an instance of Scanner class
        Scanner sc = new Scanner(System.in);
        //Declare variables
        float p, r, t;
        System.out.println("Enter the Principal : ");
        p = sc.nextFloat();     //Initialize the variables
        System.out.println("Enter the Rate of interest : ");
        r = sc.nextFloat();     //Initialize the variables
        System.out.println("Enter the Time period : ");
        t = sc.nextFloat();     //Initialize the variables
        sc.close();
        
        //Call a method to calculate the simple interest
        float interest = simpleInterest(p,r,t);
        System.out.println("Simple interest is : " + interest);

    }
    
}


Enter the Principal: 4500
Enter the Rate of interest: 12
Enter the Time period : 3
Simple interest is: 1620.0