Best Way To Find Simple Interest In Java

Sharing is healthy !!

You are here to learn the best way to find simple interest in java. Let us understand what is simple interest with an example.

what is simple interest?

Simple interest is a method to enumerate interest on invested amount or loan. It is calculated by multiplying principal amount, rate and time.

Also Read – Print Multiplication Tables Of Any Number In Java

Simple Interest = (Principal Amount * Rate * Time) / 100

example: Best Way To Find Simple Interest In Java

Let’s see an example on java interest rate program,

import java.util.Scanner;

public class SimpleInterestInJava
{ 
   public static float SimpleInterest(float valuePrinciple, float valueRate, float valueTime)
   {
      float calInterest = (valuePrinciple * valueRate * valueTime) / 100;
      return calInterest;
   }

   public static void main(String[] args)
   {
      Scanner sc = new Scanner(System.in);
      System.out.println("Best way to find Simple Interest In Java");
 
      System.out.println("Please enter principal amount: " );
      float getAmount = sc.nextFloat();
 
      System.out.println("Please enter time(in years): ");
      float getTime = sc.nextFloat();
 
      System.out.println("Please enter rate annually: ");
      float getRate = sc.nextFloat();
 
      float getInterest = SimpleInterest(getAmount, getRate, getTime);
 
      System.out.println("Simple Interest is: " + getInterest);

   }
}

Output:

Best Way To Find Simple Interest In Java


without using method

Now let’s learn java interest rate program without using method,

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 = (rate * time * principal) / 100;
      System.out.print("The Simple Interest is : " + simpleInterest);
      sc.close();
   }
}

Output:

Enter principal amount : 500000
Please enter rate annually : 2.5
Please enter time(in years) : 3
The Simple Interest is : 37500.0


conclusion

So this is all about simple interest java program. I hope you guys have understood the concept.

You can subscribe to my blog flower brackets if you haven’t already.

Do share this post if you like.

Sharing is healthy !!

You May Also Like