In this post, we are going to see how to calculate simple interest using Java. But before that, I am going to describe what simple interest is. So those of you already know what a simple interest is, you can move to the code. And those of you don’t know about simple interest, keep reading.

## Simple interest

Suppose you have applied for a loan. The rate of interest is 8%, the payment period is five years and the principle is 400000. So for this, the extra amount you are paying to the bank is called simple interest.

Now that you know what a simple interest is, it’s time to calculate it. So how do we calculate simple interest? There is a simple formula for that.

1 |
(p*t*r)/100 |

Here in the above formula, ‘p’ is the principal amount, ‘t’ is the time or the payment period and ‘r’ is the interest rate.

#### What we are going to do in this program

In this program, we are going to ask the user for the interest rate, time and principle one by one. To get user input, we will be using BufferedReader class. Based on the user input the simple interest will be calculated.

#### Complete code of the program

1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
public class simpleInterest { public static void main(String []args) throws IOException{ double interest,p,t,r; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Enter principal: "); p = Integer.parseInt(br.readLine()); System.out.print("Enter numbers of years: "); t = Integer.parseInt(br.readLine()); System.out.print("Enter rate of interest: "); r = Integer.parseInt(br.readLine()); interest = (p*t*r)/100; System.out.println("Interest: "+interest); } } |

#### Output of the program

1 2 3 4 |
Enter principal: 3037 Enter numbers of years: 3 Enter rate of interest: 8 Interest: 728.88 |