Java program to find simple interest

Let’s learn java program to find simple interest.

Java program to find simple interest

Write a java program to calculate simple interest is the one of the frequently asked question in interview.

Simple interest is used to enumerate interest on loan in banks. It is calculated by using formula,

Simple Interest = (P x R x T) / 100

P – is principal amount.

R – is rate per annum.

T – is time in years.

In the below simple interest program in java first user enters principal amount, rate and time in years using nextFloat() method of Scanner class.

These three values are stored in principal, rate and time variables of data type float.

Then find interest value in java using above formula. Let’s see java program to calculate simple interest or write a program to calculate simple interest in java.

import java.util.Scanner;
public class SimpleInterestJavaProgram
{
   public static void main(String[] args)
   {
      float principal, rate, time;
      Scanner sc = new Scanner(System.in);
      System.out.print("Enter principal amount : ");
      principal = sc.nextFloat();
      System.out.print("Please enter rate annually : ");
      rate = sc.nextFloat();
      System.out.print("Please enter time(in years) : ");
      time = sc.nextFloat();
      float simpleInterest;
      simpleInterest = (principal * time * rate) / 100;
      System.out.println("The Simple Interest is : " + simpleInterest);
      sc.close();
   }
}


Output:

java program to find simple interest

Also read – java reverse string array