# Java Program to Calculate Simple Interest

Write a Java Program to Calculate Simple Interest with an 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 program finds the simple Interest using the above-specified formula.

```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 program is the same as above, but we are creating a different method to find the Simple Interest this time.

```import java.util.Scanner;

public class ScI2 {
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();

calSimpleIntr(PAmount, ROI, TimePeriod);

}
public static void calSimpleIntr(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);
}
}```
`````` 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 Calculate 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.

```import java.util.Scanner;

public class SimIn3 {

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 =  calSimInt(PAmount, ROI, TimePeriod);
System.out.println("\n The Simple Interest for Principal Amount " + PAmount + " is = " + simpleInterset);

}
public static double calSimInt(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``````