Jan 28, 2022

Simple Interest Calculator Program - Java Program Example

Java Program To Calculate Simple Interest.   In This Post We Share A Java Program Code For Calculate Simple Interest By Read Principal Amount, Rate And Time.  When We Compile  This Program Compiler Ask To Enter Principal Amount, Rate And Time  And Show Output After Compile Java Program 


Program Code

package com.androidpro.in;

import
java.io.BufferedReader;
import
java.io.IOException;
import
java.io.InputStreamReader;
import
java.io.PrintStream;
import
java.text.ParseException;
import
java.text.SimpleDateFormat;
import
java.util.Date;
import
java.util.Scanner;

public class
Main {

   
public static void main(String[] args)
    {
       
//creating scanner to accept principle, rate and time input form user
       
Scanner scanner = new Scanner(System.in);
    
//   System.out.println("Welcome in Java program to calculate Simple interest");

       
System.err.println("Please enter principle amount :");
        float
amount = scanner.nextFloat();

       
System.err.println("Enter time in years : ");
        float
time = scanner.nextFloat();

       
System.out.println("Enter rate annually : ");
        float
rate = scanner.nextFloat();

        float
interest = simpleInterest(amount, rate, time);

       
System.out.println("Simple interested calculate by program is : " + interest);
   
}

   
public static float simpleInterest(float principle, float rate, float time){
       
float interest = (principle*rate*time)/100;
        return
interest;
   
}

}


 


Output


 

Please enter principle amount :

Welcome in Java program to calculate Simple interest

8999

Enter time in years :

90

Enter rate annually :

10

Simple interested calculate by program is : 80991.0

 

Process finished with exit code 0

Share:

0 Comments: