# Java Program to Find the Simple Interest

In the previous article, we have seen Java Program to Find Trigonometric Values of an Angel

In this article we are going to see how to find the Simple Interest using Java programming language.

## Java Program to Find the Simple Interest

Before Jumping into the program directly let’s see how to Find the Simple Interest.

Simple Interest(SI) = (P*T*R)/100

Where,

• P represents Principal Amount
• T represents Time
• R represents Rate of Interest

Example:

Let
P = 20
R = 5
T = 1
SI = (P*R*T)/100 = 1

Let’s see different ways to find Simple Interest.

### Method-1: Java Program to Find the Simple Interest By Using Static Input Value

Approach:

• Declare a double variable say ‘p’ and assign the value to it, which holds the value of the principal amount.
• Declare a double variable say ‘r’ and assign the value to it, which holds the value of the rate of interest.
• Declare a double variable say ‘t’ and assign the value to it, which holds the value of time of interest.
• Declare a double variable say ‘si’ which will hold the value of simple interest.
• Using the formula (p*t*r)/100 find simple interest.
• Print the result.

Program:

import java.util.*;
class Main
{
public static void main(String [] args)
{
//declared the value of p,t and r
double p = 20000;
double r = 5;
double t = 1;
//finding simple interest by using the formula
double si =  (p*t*r)/100;
System.out.println("The simple interest is: " + si);
}
}


Output:

The simple interest is: 1000.0

### Method-2: Java Program to Find the Simple Interest By Using User Input Value

Approach:

• Declare a double variable say ‘p’ to hold the value of the principal amount and take the value as user input.
• Declare a double variable say ‘r’ to hold the value of the rate of interest
• Declare a double variable say ‘t’ and assign the value to it, which holds the value of time of interest.
• Declare a double variable say ‘si’ to hold the result i.e. value of the simple interest.
• Using the formula (p*t*r)/100 find simple interest.
• Print the result.

Program:

import java.util.*;
class Main
{
public static void main(String [] args)
{
//Scanner class object created
Scanner s = new Scanner(System.in);
//Taking the value of p,t and r as user input
System.out.println("Enter the value of principal amount:");
double p = s.nextDouble();
System.out.println("Enter the value of rate of interest:");
double r = s.nextDouble();
System.out.println("Enter the value of time:");
double t = s.nextDouble();

//finding simple interest by using the formula
double si =  (p*t*r)/100;
System.out.println("The simple interest is: " + si);
}
}


Output:

Enter the value of principal amount:
10000
Enter the value of rate of interest:
5
Enter the value of time:
4
The simple interest is: 2000.0

### Method-3: Java Program to Find the Simple Interest By Using User Defined Method

Approach:

• Declare a double variable say ‘p’ to hold the value of the principal amount and take the value as user input.
• Declare a double variable say ‘r’ to hold the value of the rate of interest
• Declare a double variable say ‘t’ and assign the value to it, which holds the value of time of interest.
• Declare a double variable say ‘si’ to hold the result i.e. value of the simple interest.
• Call a user defined method simpleInterest() with parameter p, t and r as parameter to find simple interest
• Inside the method by using the formula (p*t*r)/100 find simple interest.
• Print the result.

Program:

import java.util.*;
class Main
{
public static void main(String [] args)
{
//Scanner class object created
Scanner s = new Scanner(System.in);
//Taking the value of p,t and r as user input
System.out.println("Enter the value of principal amount:");
double p = s.nextDouble();
System.out.println("Enter the value of rate of interest:");
double r = s.nextDouble();
System.out.println("Enter the value of time:");
double t = s.nextDouble();
//calling simpleInterest() method
simpleInterest(p,t,r);
}

//simpleInterest() user defined method to find simple interest
public static void simpleInterest(double p, double t, double r)
{
//finding simple interest by using the formula
double si =  (p*t*r)/100;
System.out.println("The simple interest is: " + si);
}
}


Output:

Enter the value of principal amount:
100000
Enter the value of rate of interest:
5.5
Enter the value of time:
10
The simple interest is: 55000.0

Provided list of Simple Java Programs is specially designed for freshers and beginners to get familiarize with the concepts of Java programming language and become pro in coding.

Related Java Programs: