# Java Program to Calculate Simple Interest

Write a Java Program to Calculate Simple Interest with example. The formula behind this Simple Interest calculation is

Simple Interest = (Principal Amount * Rate of Interest * Number of years) / 100

## Java Program to Calculate Simple Interest Example 1

This Java program allows the user to enter the Principal Amount, total Number of years, and Interest Rate. By using those values, this Java program finds the simple Interest using the above-specified formula.

```// Java Program to Calculate Simple Interest
import java.util.Scanner;

public class SimpleInterest1 {

private static Scanner sc;
public static void main(String[] args)
{
double PAmount, ROI, TimePeriod, simpleInterset;
sc = new Scanner(System.in);

System.out.print(" Please Enter the Principal Amount : ");
PAmount = sc.nextDouble();

System.out.print(" Please Enter the Rate Of Interest : ");
ROI = sc.nextDouble();

System.out.print(" Please Enter the Time Period in Years : ");
TimePeriod = sc.nextDouble();

simpleInterset = (PAmount * ROI * TimePeriod) / 100;

System.out.println("\n The Simple Interest for Principal Amount " + PAmount + " is = " + simpleInterset);
}
}```

## Java Program to find Simple Interest Example 2

This Java program is the same as above. But this time, we are creating a separate Java method to find the Simple Interest.

```// Java Program to Calculate Simple Interest
import java.util.Scanner;

public class SimpleInterest2 {
private static Scanner sc;
public static void main(String[] args)
{
double PAmount, ROI, TimePeriod;
sc = new Scanner(System.in);

System.out.print(" Please Enter the Principal Amount : ");
PAmount = sc.nextDouble();

System.out.print(" Please Enter the Rate Of Interest : ");
ROI = sc.nextDouble();

System.out.print(" Please Enter the Time Period in Years : ");
TimePeriod = sc.nextDouble();

calSimpleInterest(PAmount, ROI, TimePeriod);

}
public static void calSimpleInterest(double PAmount, double ROI, double TimePeriod)
{
double simpleInterset;

simpleInterset = (PAmount * ROI * TimePeriod) / 100;

System.out.println("\n The Simple Interest for Principal Amount " + PAmount + " is = " + simpleInterset);
}
}```

Java simple interest output

`````` Please Enter the Principal Amount : 500000
Please Enter the Rate Of Interest : 9.75
Please Enter the Time Period in Years : 7

The Simple Interest for Principal Amount 500000.0 is = 341250.0``````

## Java Program to find Simple Interest Example 3

Instead of printing the Simple Interest from a method, this program returns a value. Next, within the main Java program, we assign the return value to another variable.

```// Java Program to Calculate Simple Interest
import java.util.Scanner;

public class SimpleInterest3 {

private static Scanner sc;
public static void main(String[] args)
{
double PAmount, ROI, TimePeriod, simpleInterset;
sc = new Scanner(System.in);

System.out.print(" Please Enter the Principal Amount : ");
PAmount = sc.nextDouble();

System.out.print(" Please Enter the Rate Of Interest : ");
ROI = sc.nextDouble();

System.out.print(" Please Enter the Time Period in Years : ");
TimePeriod = sc.nextDouble();

simpleInterset = calSimpleInterest(PAmount, ROI, TimePeriod);
System.out.println("\n The Simple Interest for Principal Amount " + PAmount + " is = " + simpleInterset);

}
public static double calSimpleInterest(double PAmount, double ROI, double TimePeriod)
{
double simpleInterset;

simpleInterset = (PAmount * ROI * TimePeriod) / 100;

return simpleInterset;
}
}```
`````` Please Enter the Principal Amount : 1200000
Please Enter the Rate Of Interest : 7.5
Please Enter the Time Period in Years : 9

The Simple Interest for Principal Amount 1200000.0 is = 810000.0``````